Re: How to get ssh to work in a loop

From: Peter Jones (petejones1974_at_hotmail.com)
Date: 12/12/03


Date: 12 Dec 2003 03:11:04 -0800

I'm still unable to get the loop to work.
I run the following command to create a file called /tmp/lrgfiles on
the remote server:

ssh $HOST "cut -d ' ' -f2 /etc/mnttab | grep ora > /tmp/lrgfiles"

I then want to perform some processing on this file on the remote
server but get the results on the local system.

Below is the for loop that I want to perform on the remote server
using ssh to connect. How do I get this loop to run using ssh and how
can I get the output back to the local system?
 
for i in `cat /tmp/lrgfiles`
do
        fsadm -F vxfs $i | grep nolarge > /dev/null
        if [ $? = 0 ]
        then
                echo $i
        fi
done >> /tmp/output

All help greatly appreciated.
Cheers
Pete

Kevin Rodgers <ihs_4664@yahoo.com> wrote in message news:<3FCCBF7F.7060404@yahoo.com>...
> [Please don't top-post.]
>
> Mike Cross wrote:
>
> > The for loop scrambles stdin, which upset, ssh/rsh, I get around ths by
> > using while loop:
> >
> >
> > while read line
> > do
> > ..
> > ..
> > rsh $line date
> > ..
> > done < file
> >
> > works OK
>
>
> No, it doesn't. The body of the while ... done loop inherits its file
> descriptors, and the rsh command still consumes all of the remaining
> data in standard input. The way to get around this problem is to
> redirect rsh's standard input
>
> rsh $host ... < /dev/null
>
> or use the command line option provided for this purpose
>
> rsh -n $host ...



Relevant Pages

  • Sol8 and EVA hangs
    ... Secure Path 3.0D is loaded for channel failover. ... retrying command ... # Adapter hard loop ID address to use on the fibre channel bus. ...
    (SunManagers)
  • Summary: Sol8 and EVA hangs
    ... Oct 8 11:00:41 proddb SCSI transport failed: reason 'aborted': ... retrying command ... # Adapter hard loop ID address to use on the fibre channel bus. ... # before reporting I/O errors. ...
    (SunManagers)
  • Re: Installing TDK 4.0.4 trial with Tcl 8.5.1...
    ... Locate an ActiveTcl 8.4.9.1+ installation for use by the Tcl Dev Kit demos. ... Then the TDK installer continues with: ... remote server cannot handle this command ...
    (comp.lang.tcl)
  • Installing TDK 4.0.4 trial with Tcl 8.5.1...
    ... Locate an ActiveTcl 8.4.9.1+ installation for use by the Tcl Dev Kit demos. ... remote server cannot handle this command ...
    (comp.lang.tcl)
  • Re: Using foreach loop to create radiobutton menu
    ... Your foreach loop is not the problem, the problem is how you define the -command. ... The only possible thing the interpreter can do is substitute the current value of range, which is likely the last value once your loop exited. ... One choice is double quotes. ... The double quotes means that $range gets expanded while in the loop, long before the puts command actually runs. ...
    (comp.lang.tcl)