![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| running a batch file in loop | aemunathan | Shell Programming and Scripting | 1 | 05-21-2008 02:11 AM |
| SFTP in batch Mode | ilok | AIX | 1 | 08-28-2007 01:25 AM |
| Sftp in Batch Mode | sivaemn | UNIX for Advanced & Expert Users | 2 | 07-01-2007 06:52 AM |
| su command in batch mode | Rajesh Gohad | Shell Programming and Scripting | 3 | 01-26-2007 12:54 AM |
| SFTP in batch mode | mlim1111 | Shell Programming and Scripting | 5 | 01-23-2006 04:03 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
SSH in batch mode and File-Handles in a loop
Hi all
I try to execute SSH commands on several hosts in a while-loop. There seems to be a problem with file-handle, first cycle works correct but no other one will follow due to the while condition is false even that there are many more host entries (lines) in all_hosts.dat. #!/usr/bin/ksh exec 0<all_hosts.dat while read line do echo "...executing on host :" $line ssh $line 'ls -la /tmp' # execution aborts after the first cycle ###pwd | ssh $line 'ls -la /tmp' # continues for each entry of all_hosts.dat done # <all_hosts.dat # Any clue? Any pointer to explaining tutorials about file handles? MTIA Dave |
|
||||
|
I too get the same error,ie the SSH session is entered once, in case of while loop.
But it doesnot seems to happen if i use for inplace of while for host in $(</tmp/hosts); do echo "Executing on the $host" ssh $host 'ls -lrt /tmp' echo $host done cat /tmp/hosts user1@localhost remote@localhost others@localhost Gurus, Help us why did the code as in OP using the while doesnot work,but using the for loop is works? Thanks Nagarajan Ganesan |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|