Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Ssh to remote server loop is breaking

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-17-2013
raghur77 raghur77 is offline
Registered User
 
Join Date: Jun 2009
Last Activity: 8 July 2016, 5:45 AM EDT
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Linux Ssh to remote server loop is breaking

hi All,

cat login.list

Code:
server1 userid1
server2 userid2
server3 userid3

----------------------------------------


Code:
#SSHSCRIPT.ksh
FILE=login.list
 
while read vah vah_id
do
       ssh  $vah -l $vah_id "pwd"
done < "$FILE"

-----------------------------------------

When i execute ksh -x SSHSCRIPT.ksh it executes only one loop and exist, Please assist me here

OUTPUT:

Code:
 ksh -x SSHSCRIPT.ksh 
 + FILE=login.list
 + read vah vah_id
+ IFS=
+ ssh server1 -l userid1 pwd
/server1/admin
+ read vah vah_id
+ IFS=


Last edited by Franklin52; 01-17-2013 at 04:27 AM.. Reason: Please use code tags for data and code samples
Sponsored Links
    #2  
Old Unix and Linux 01-17-2013
Scott's Unix or Linux Image
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 24 August 2016, 1:39 AM EDT
Location: Zürich
Posts: 8,595
Thanks: 342
Thanked 1,092 Times in 948 Posts
This is a fairly common question.

The fairly common answer is to use the -n option of SSH.
Sponsored Links
    #3  
Old Unix and Linux 01-17-2013
raghur77 raghur77 is offline
Registered User
 
Join Date: Jun 2009
Last Activity: 8 July 2016, 5:45 AM EDT
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
it worked with -n option.
thank you very much.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
while loop stops after first iteration - remote ssh exit command problem? jelloir Shell Programming and Scripting 3 02-10-2012 12:50 AM
Running for loop on remote server sexyTrojan Shell Programming and Scripting 6 03-14-2010 03:13 AM
SSH Remote Server issue la_womn Shell Programming and Scripting 1 05-20-2008 03:17 PM
automatic ssh into remote server using ksh tekline Shell Programming and Scripting 4 07-23-2007 01:35 PM



All times are GMT -4. The time now is 11:04 AM.