WebFaction
Community site: login faq

I have a script which executes a script remotely on another machine with the 'ssh' command. I'm trying to run this as part of a cgi bash script on a website, but whenever ssh is called it doesn't seem to execute (the line doesn't produce any output). I tried executing a number of other commands which correctly lists their help text when called without parameters, and I tried passing an absolute path for ssh, but I couldn't get it to output anything. I installed sshpass into my local bin folder, which I was able to also have output the help text normally.

Is there something special about ssh and why this wouldn't work for it specifically? Has it been blocked in the Apache settings in some way? And is there a way to enable it so that it can be executed?

Furthermore, once (and if) I'm able to execute, can I call ssh directly from a bash cgi script, or would I need to spawn a separate process for it, or something else?

I'm running this through a Static/CGI/PHP website, which I believe is running under Apache.

asked 07 Aug '13, 19:12

mkylmamaa
3112
accept rate: 0%


SSH requires stdin and stdout, which won't work quite right within a GCI process.

You have generally 2 options,

  1. Use a library which deals with stdin and stdout, such as expect.
  2. Make your code add and than remove 1 line to the crontab which actually executes your script.
permanent link

answered 08 Aug '13, 00:27

johns
5.4k312
accept rate: 23%

I almost forgot this option, 3. use python's fabric library.

(08 Aug '13, 00:28) johns

Thanks. Expect seems like it should be an easy extension for the bash script, so I'll give that a try.

(08 Aug '13, 14:37) mkylmamaa
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×103
×31

question asked: 07 Aug '13, 19:12

question was seen: 11,686 times

last updated: 08 Aug '13, 14:37

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM