This is my shell script

echo "Content-type: text/plain"
echo ""

sshpass -p $pass ssh -v -p $port -t -o StrictHostKeyChecking=no root@$ip "cd / && ls && exit"

It can be executed via web, or via command line.

When executed via command line I see lots of output.. including debug info from "-v" (verbose mode), etc.

But when executed via web, all I see is the listing of folders (executed command's output). No other data.

Why is the extended data missing when I execute this script via web? Why is it there when I execute it via command line?

How can I make sure it is also there when executed via web?


1 Answer 1


Your "extra data" is being sent by your script to standard error, not standard output.

why is the extended data missing when i execute this script via web ?

Because the CGI interface used between the seb server and your script only takes your script's standard output stream into account, not its standard error stream. The standard error is going elsewhere, possibly to the web server's error log, possibly nowhere.

why is it there when i execute it via command line ?

Because in a terminal, standard output and standard error go by default to the same place, which is the terminal itself.

how can i make sure it is also there when executed via web ?

You can redirect standard error to the same place as standard output:

exec 2>&1

(file descriptor 2 is standard error, file descriptor 1 is standard output.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .