From: Ken McCoy <kenm () apscn ! k12 ! ar ! us>
To: tru64-unix-managers
Subject: SUMMARY: bug in while-do/done and rsh in shell scripts ????
Date: Fri, 09 Jan 1998 09:46:59 +0000 [thread overview]
Message-ID: <96078654410731.tru64-unix-managers.marc@archive.invalid> (raw)
Thanks to all who replied!!
The answer was to put a "-n" on the rsh command.
All replies follow:
============================
You will have to redirect rsh's standard input to /dev/null
i.e.
rsh xhost ls -al /soft/bin/$line < /dev/null
or use rsh with the -n option. This is no bug. Rsh just uses
up all the input for the loop.
Gerhard
--
Gerhard Kircher kircher@edvz.tuwien.ac.at
Vienna University of Technology phone: +43 1 588 01 5599
Computing Services fax : +43 1 587 42 11
Wiedner Hauptstrasse 8-10, A-1040 Vienna, Austria
=================================================
I am suspicious of your attempt to pipe the output of "ls" into
the "while" command. I don't think that will work. Why not
use the "for" command to run through the output produced by "ls"
and captured by command substitution, e.g.,
for line
in `ls`
do
rsh xhost ls -al /soft/bin/$line
done
-Phil Farrell, Computer Systems Manager
Stanford University School of Earth Sciences
farrell@pangea.stanford.edu
==============================================
Try the following instead
while LINE in `ls`
do
rsh xhost ls -al /soft/bin/$LINE
done
Note that since you are using rsh you might need to use the full path
for ls (/usr/bin/ls I believe).
--
Thank you,
Andrew Weston
(Network Adminstrator)
Note: Any comments I may make are not necessarily those of my
employer.
+---------------------------------------------------------------------
+----+
| Adacel Technologies Ltd., 250 Bay st Brighton Victoria 3182
Australia | | email: andreww@adacel.com.au ph: +61 3 9596-2991 fax:
+61 3 9596 2960 |
+---------------------------------------------------------------------
----+
===================================================
Try a rsh -n, this is a fix when the remote account is csh
-Stephen
g GE Capital
Information Technology Solutions WISE Project
________________________________________________________
Stephen Mullin phone:_____ (770)300-3373
WISE Project (SAP) dialcomm:____ 8* 270-3373
GE Capital IT Solutions fax:________ (770)416-9592
2825a Pacific Drive
Norcross, GA 30071
smullin@gecits.ge.com
===================================================
perhaps, you might try one of these
for File in *
do rsh xhost 'ls -al /soft/bin/$File'
done
ls -1 > /tmp/tmpfile.$$
while read line
do rsh ...
done < tmpfile
rm /tmp/tmpfile.$$
I might prefer something like...
#!/usr/bin/ksh
TmpFile=/tmp/tmp$$
exec 3< $TmpFile
while read -u3 line
do rsh ...
done
You probably get several dozen ways of doing this. It really
depends
on what you're doing.
may I ask, are you looking to see if two areas on seperate
systems contain
identically named files? If this is the case, then
you might look at
a tool called rdist or nrdist.
enjoy,
/sb
=========================================
Try the -n flag with rsh:
-n Redirects any input for rsh to the /dev/null device. Use this
flag if
you are in C shell and run rsh in the background.
I don't know that this will do it, but it's worth a try. It makes all
the difference in the world in my testing with the Bourne shell
driving the test. Don't ask how I knew about that flag off the top of
my head..
Tom
Dr. Thomas P. Blinn, UNIX Software Group, Digital Equipment
Corporation
110 Spit Brook Road, MS ZKO3-2/U20 Nashua, New Hampshire
03062-2698
Technology Partnership Engineering Phone: (603) 884-0646
Internet: tpb@zk3.dec.com Digital's Easynet: alpha::tpb
ACM Member: tpblinn@acm.org PC@Home: tom@felines.mv.net
Thanks
------------------------------------
Ken McCoy
Arkansas Public School Computer Net.
reply other threads:[~1998-01-09 9:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox