The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do i get current bandwidth usage via shell script? scarfake Shell Programming and Scripting 2 05-25-2008 07:27 PM
shell script to send email with usage of space in the directory as description : sakthifire Shell Programming and Scripting 3 04-18-2008 01:27 AM
shell script extended usage... joerg535 UNIX for Dummies Questions & Answers 1 08-24-2007 07:02 AM
time command usage in sh script kris_search Shell Programming and Scripting 7 03-09-2007 10:40 AM
Monitor CPU usage and Memory Usage Gajanad Bihani High Level Programming 2 03-09-2005 03:35 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Dec 2006
Posts: 16
Stumble this Post!
SSH usage in a script

I have configured ssh to a remote server without prompting for a password with the help of public keys...but now i am not able to execute any commands through a script

what i want is a one line script which takes me directly into /var directory after executing it...searched the entire forum but couldnt find a solution to this prob...

i have tried...

ssh username@hostname "cd /var"
ssh username@hostname [cd /var]
ssh username@hostname ; cd /var
ssh username@hostname | cd /var

nothing seems to work :-(
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-14-2007
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,325
Stumble this Post!
Er, what exactly are you trying to do? And how do you know that the command
Code:
ssh username@hostname "cd /var"
didn't work? Are you expecting that you will get a prompt after doing the cd to /var? If so, you are mistaken. Try executing this:
Code:
ssh username@hostname "uname -a; cd /var; pwd"
You will see that you are indeed on the remote server and in the /var directory. However you aren't specifying any more actions to be carried out, so your ssh command is getting completed and exiting.
Reply With Quote
  #3 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Dec 2006
Posts: 16
Stumble this Post!
thanks

Gr8!! now i am getting my commands to execute...didnt know ssh returns back after executing :-) Thanks...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:18 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0