Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-06-2009
Dicloflex Dicloflex is offline
Registered User
 

Join Date: Nov 2009
Posts: 4
Reading a file with while into variable and using in another process

I would appreciate some help, please.

I have a file cutshellb.txt, which contains four report names (but it could be any number from 1 to x. The report suffix is not necessarily consecutive:

report3785
report3786
report3787
report3788

I have a shell script which attempts to read the names and use them as a parameter in another script to run a mail package:


Code:

#!/bin/ksh
for line in `/usr/bin/cat /u1/cutshellb.txt`; do
 /u1/sendreportmail.sh MYPRT=$(`echo "$line"`) 1>sendmail.log 2>&1
done

The script contains:


Code:

cd /u1/mail/bin/
./mailsend -i -vvvv   -tany_person@mailaddress.uk -s "Mail report " 
 -a/u1/$MYPRT.pdf "  "

I would appreciate some pointers - even if it is just that this is not possible.

I found this format MYPRT=$(`echo "$line"`) on a website which suggested that there are difficulties with passing variables between parent and child processes with pipes especially within ifs and whiles.

Last edited by pludi; 11-06-2009 at 01:43 PM.. Reason: code tags, please...
Sponsored Links