while script

while script

Post by srikan » Wed, 03 Apr 2002 14:12:55



Please help me what's the problem with the script.  WHen i run
as it is, it exits after processing the first line of 'found' file.

#! /sbin/sh
cat /home/xxx/found |while read line
do
f1=`echo $line | awk -F, '{print $1}'`
f6=`echo $line | awk -F, '{print $6}'`
f7=`echo $line | awk -F, '{print $7}'`
hostid=xxxxxxxx
ping $f6 && hostid=`rsh $f6 hostid`
echo $f1 $hostid $f7
done

If i comment out ping statement, i can see all the lines in 'found' file
getting processed. Any help is highly valued.

 
 
 

while script

Post by Kenneth C Stah » Wed, 03 Apr 2002 21:50:47



> Please help me what's the problem with the script.  WHen i run
> as it is, it exits after processing the first line of 'found' file.

> #! /sbin/sh
> cat /home/xxx/found |while read line
> do
> f1=`echo $line | awk -F, '{print $1}'`
> f6=`echo $line | awk -F, '{print $6}'`
> f7=`echo $line | awk -F, '{print $7}'`
> hostid=xxxxxxxx
> ping $f6 && hostid=`rsh $f6 hostid`
> echo $f1 $hostid $f7
> done

> If i comment out ping statement, i can see all the lines in 'found' file
> getting processed. Any help is highly valued.

The main thing wrong with it is that you are trying to hack someone's
system.

 
 
 

while script

Post by Barry Margoli » Wed, 03 Apr 2002 23:51:44




>Please help me what's the problem with the script.  WHen i run
>as it is, it exits after processing the first line of 'found' file.

>#! /sbin/sh
>cat /home/xxx/found |while read line
>do
>f1=`echo $line | awk -F, '{print $1}'`
>f6=`echo $line | awk -F, '{print $6}'`
>f7=`echo $line | awk -F, '{print $7}'`
>hostid=xxxxxxxx
>ping $f6 && hostid=`rsh $f6 hostid`
>echo $f1 $hostid $f7
>done

>If i comment out ping statement, i can see all the lines in 'found' file
>getting processed. Any help is highly valued.

rsh is reading its standard input and sending it to the remote system, in
case the remote command needs input.  Its standard input is the pipe from
cat.

Use the -n option to rsh.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

while script

Post by srikan » Thu, 04 Apr 2002 10:04:26


Thank you, it worked..

Srikanth




>Please help me what's the problem with the script.  WHen i run
>as it is, it exits after processing the first line of 'found' file.

>#! /sbin/sh
>cat /home/xxx/found |while read line
>do
>f1=`echo $line | awk -F, '{print $1}'`
>f6=`echo $line | awk -F, '{print $6}'`
>f7=`echo $line | awk -F, '{print $7}'`
>hostid=xxxxxxxx
>ping $f6 && hostid=`rsh $f6 hostid`
>echo $f1 $hostid $f7
>done

>If i comment out ping statement, i can see all the lines in 'found' file
>getting processed. Any help is highly valued.

rsh is reading its standard input and sending it to the remote system, in
case the remote command needs input.  Its standard input is the pipe from
cat.

Use the -n option to rsh.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the
group.

 
 
 

1. Press Ctrl-D whiling inputting

I write a program:

#include <stdio.h>
main()
{
   char str[81];
   while(1)
   {
      gets(str);
      printf("You input: %s\n",str);
   }

My question is why it causes infinitely loop after I press Ctrl-D.
Is there any solution about this?  Thanks.

--
     +------------------------------------------------------------+
    / \   Trying to maintain a good friendship with all people   / \
   /   + - - - - - - - - - - - - - - - - - - - - - - - - - - - -/ - +


+------------------------------------------------------------+   /
 \ /Home Page: http://susis.ust.hk/~enoch                     \ /
  +------------------------------------------------------------+

2. Accelerating user mode linux

3. Execute a sh script under perl and sh: sh script; perl script?

4. Netscape mouse locks up under Solaris 2.5

5. cgi scripts showing up as script rather as binary

6. Need advice about how to write network/X application.

7. 'script' in a cron initiated ksh script

8. Help

9. handling SIGINT in shell scripts when executing another shell script.

10. returning control back to my script after spawning another script

11. Initialization script for bash script

12. How do you pass a value from a shell script into a sqlplus script?

13. Script to create startup scripts in /etc/init.d or /etc/rc?.d