Teen Programmers Unite  
 

 

Return to forum top

A simple shell prog problem

Posted by manoj [send private reply] at September 10, 2002, 01:27:34 PM

Here is a shell prog : eid
for STR in $*
do
echo "$STR@hotmail.com"
done

If I run it as : eid A B C
o/ps are A@hotmail.com etc.
If I run it as eid < names
where names is a file containing some strings. it dooesn't work. What is the problem?
Also, if it can't be done this way, can it be done anyhow without using gawk etc.
PS:I'm new to shell prog

Posted by Psion [send private reply] at September 10, 2002, 02:30:39 PM

Using < names hooks standard input up to the file `names'. i.e., "prog < names" runs prog with no parameters, and then acts as if you typed the contents of `names' on the kyeboard. $* looks at command line arguments, which is something completely different.

Posted by buzgub [send private reply] at September 10, 2002, 11:59:47 PM

something like:

 eid `cat names` 

may do what you want. If it doesn't, try replacing all the newlines in 'names' with spaces.
Posted by manoj [send private reply] at September 21, 2002, 10:53:13 PM

yeah thnx.......it was soooooo stupid!!

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.