The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Bash Script to check Remote Host Connection zulfikarmd UNIX for Dummies Questions & Answers 5 04-16-2008 06:53 AM
Sending Commands to a Remote Host safetytrick UNIX for Dummies Questions & Answers 3 08-18-2007 06:29 PM
How can my unix shell script automatically connect to remote host? digdarshan Shell Programming and Scripting 8 06-29-2007 11:44 PM
How to delete the files from local host to remote host krishna176 SUN Solaris 3 03-24-2007 04:48 PM
QNX host cannot ping SCO host, vice versa gavon IP Networking 2 08-20-2001 08:57 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-08-2009
SN2009 SN2009 is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 3
Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running after ssh is executed...

Any help appreciated
  #2 (permalink)  
Old 04-08-2009
nirbhay nirbhay is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 8
remsh is the answer

remsh <machine> -l <acc> -n "<whatever you wanna do on remote side>"
  #3 (permalink)  
Old 04-08-2009
TonyFullerMalv's Avatar
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Location: Malvern, Worcs. U.K.
Posts: 730
or you could ssh like this:
Code:
$ ssh machinename command
e.g.
Code:
$ ssh sunhost "uname -n"
If you want to run this without providing a password you will need to generate keys on the clients and install them into the ~/.ssh/authorized_keys file at the remote machine end, see: How to set up ssh so you aren't asked for a password
  #4 (permalink)  
Old 04-13-2009
SN2009 SN2009 is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 3
I used ssh hostname "command " and it does work for me if its a single command. But then there is a bunch of commands. let say I need to go to a specific folder in the remote host and then have to run some commands and so on ...... so how can I do that
  #5 (permalink)  
Old 04-13-2009
nirbhay nirbhay is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 8
any of them can work. you just have to seperate your commands by semicolon & include all of them in quotes. somethin like this

Code:
remsh <machine> -l <account> -n "cd users; ls -l"
i hope u get it.
  #6 (permalink)  
Old 04-13-2009
amitranjansahu's Avatar
amitranjansahu amitranjansahu is offline
Registered User
  
 

Join Date: Jan 2009
Location: Gurgaon,INDIA
Posts: 239
bellow is a sample for you
================
ssh -n -l username ipadd ". ~/.profile >/dev/null 2>/dev/null; your commands in dest server"

say for example
ssh -n -l amit 101.10.10.10 ". ~/.profile >/dev/null 2>/dev/null; cd log ;ls | wc -l"
  #7 (permalink)  
Old 04-13-2009
SN2009 SN2009 is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 3
Yeah it worked . Thanks a lot
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0