LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: 36
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?
 
Old 03-23-2010, 06:44 AM   #2
smoker
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

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"

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

Rep: Reputation: 58
Try keeing the command in the double quotes.
Code:
$command="cat /root/vm.cfg"
ssh -ttq root@10.180.8.236 "$command"
 
Old 03-23-2010, 11:37 PM   #4
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Original Poster
Rep: Reputation: 36
still not able to get the proper output.

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

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

Where is that coming from?
 
  


Reply


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 08:24 AM
Script Execution Help Needed. pinga123 Linux - Newbie 7 11-04-2009 01:31 AM
Remote execution over SSH - incomplete environment echa Linux - Server 5 10-06-2009 10:14 AM
commande execution with sudo(on ssh) yousmg Linux - Security 4 06-14-2007 11:04 AM
Automated execution of a command on a remote system via SSH GUIPenguin Linux - General 1 02-28-2006 11:23 PM


All times are GMT -5. The time now is 11:58 PM.

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