about ssh remote

D

debbie523

I have a cgi script named test12.cgi
There is a line

$output=`ssh -l userName serverName echo hello`;
print $output;

(username is my account name, serverName is the server name)

test12.cgi is my action for try.php file. When I test this line through
browser, $output is nothing.

But if I execute test12.cgi in command window, it does print "hello"

Is there somebody could tell me why it does not show anything from the
browser?
 
G

Gunnar Hjalmarsson

debbie523 said:
I have a cgi script named test12.cgi
There is a line

$output=`ssh -l userName serverName echo hello`;
print $output;

(username is my account name, serverName is the server name)

test12.cgi is my action for try.php file. When I test this line through
browser, $output is nothing.

But if I execute test12.cgi in command window, it does print "hello"

Is there somebody could tell me why it does not show anything from the
browser?

The command failed?

Please read the docs about the backticks operator in "perldoc perlop"
for examples on how a command's STDERR can be captured.
 
T

Tad McClellan

debbie523 said:
$output=`ssh -l userName serverName echo hello`;
When I test this line through
browser, $output is nothing.

But if I execute test12.cgi in command window, it does print "hello"


perldoc -q CGI

What is the correct form of response from a CGI script?

My CGI script runs from the command line but not the browser. (500
Server Error)

How can I get better error messages from a CGI program?

Is there somebody could tell me why it does not show anything from the
browser?


We have not been given enough information to help you with that.
 
J

Joe Smith

debbie523 said:
I have a cgi script named test12.cgi
There is a line

$output=`ssh -l userName serverName echo hello`;
print $output;

You neglected to specify how it should create a password-less connection.

$output = `ssh -i $HOME/.ssh/id_rsa -l userName serverName echo hello`;

However, even that won't work.

Under CGI execution:
1) you cannot assume that the current working directory has been set.
2) you can assume that $USER, $HOME, and other variables are _not_ set.
3) many web servers execute CGI programs with UID=nobody, which means
private files (readable by only yourself) cannot be accessed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top