LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ssh execution help needed. (https://www.linuxquestions.org/questions/linux-newbie-8/ssh-execution-help-needed-797258/)

pinga123 03-23-2010 06:21 AM

ssh execution help needed.
 
I m writing a program to execute remote script .
(display remote file content)
Whenever i execute following statement it gives me an error.



PHP Code:

$command="cat /root/vm.cfg"
ssh -ttq root@10.180.8.236 $command 

However following script work find.

PHP Code:

ssh -ttq root@10.180.8.236 cat /root/vm.cfg 

I have added rsa key so that it should not ask for any password while doing ssh.


What is wrong with using variable in ssh.
What could be the issue here?

smoker 03-23-2010 06:44 AM

Are you doing this in php or bash ?

commands in bash are like

Code:

command="cat /root/vm.cfg"
$(ssh -ttq root@10.180.8.236 "$command")

if you want to capture the output of the command you do

Code:

command="cat /root/vm.cfg"
variable=$(ssh -ttq root@10.180.8.236 "$command")
echo "$variable"


PMP 03-23-2010 07:15 AM

Try keeing the command in the double quotes.
Code:

$command="cat /root/vm.cfg"
ssh -ttq root@10.180.8.236 "$command"


pinga123 03-23-2010 11:37 PM

still not able to get the proper output.

Error: Unable to open config file: /root/vm.cfg

Tinkster 03-24-2010 12:00 AM

That's a strange error message, doesn't come from cat OR ssh ...

Where is that coming from?


All times are GMT -5. The time now is 03:26 AM.