Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-23-2010, 07:21 AM   #1
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 37
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@ $command 
However following script work find.

PHP Code:
ssh -ttq root@ 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?
Old 03-23-2010, 07:44 AM   #2
Senior Member
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
Are you doing this in php or bash ?

commands in bash are like

command="cat /root/vm.cfg"
$(ssh -ttq root@ "$command")
if you want to capture the output of the command you do

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

Last edited by smoker; 03-23-2010 at 07:47 AM.
Old 03-23-2010, 08:15 AM   #3
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
Try keeing the command in the double quotes.
$command="cat /root/vm.cfg"
ssh -ttq root@ "$command"
Old 03-24-2010, 12:37 AM   #4
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
still not able to get the proper output.

Error: Unable to open config file: /root/vm.cfg
Old 03-24-2010, 01:00 AM   #5
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

Where is that coming from?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Execution of a script -Urgent help needed?? anish2343 Linux - Software 4 11-06-2009 09:24 AM
Script Execution Help Needed. pinga123 Linux - Newbie 7 11-04-2009 02:31 AM
Remote execution over SSH - incomplete environment echa Linux - Server 5 10-06-2009 11:14 AM
commande execution with sudo(on ssh) yousmg Linux - Security 4 06-14-2007 12:04 PM
Automated execution of a command on a remote system via SSH GUIPenguin Linux - General 1 03-01-2006 12:23 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:08 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration