line commandes does not work in a script

January 5, 2012 at 09:30:53
Specs: unix
Hi,

if i do this in the line command it's working:

ls I*.pdf > toto
cat toto | while read LINE
do
uuencode $LINE file.pdf | mailx -m -s "tes" email@abc.com
done

if i put the lines inside a script and run the script, it does not work.

what am i missing?

regards


See More: line commandes does not work in a script

Report •

#1
January 5, 2012 at 10:39:12
Are you getting error messages?? Did you give your script execute permissions? something like this:

chmod 755 thescript

I have a few suggestions.

On line, column 1, declare your shell, ksh, sh, etc.

use ls -1 to ensure you get one file name per line and you don't need the temp file toto

What is the -m option of mailx? I have never heard of it.

Surround the variable by double quotes:

#!/bin/ksh

# untested
# that is a -1 (one)
ls -1 I*.pdf | while read LINE
do
    uuencode "$LINE" file.pdf | mailx -m -s "tes" email@abc.com
done




Report •

#2
January 10, 2012 at 07:13:13
Hi,

-m is do not add MIME header lines to the email.

Did not get any error messages and my script has the execute permission.
rwxr-xr-x

thanks for the info, i'll try your suggestion and let you know

PB


Report •
Related Solutions


Ask Question