Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why are the results different? 1

Status
Not open for further replies.

volcano

Programmer
Aug 29, 2000
136
HK
Hello guys and gals, I have prepared a command to execute in Solaris OS. There are 2 files which contain my command. The command in both files is the same, but I wonder very much why the first file executes successfully but the second one fails:

First file contains:
( uuencode file1 file1; uuencode file2 file2; ) | mailx -s "test1" abc@abc.com


Second file contains:
LIST="uuencode file1 file1; uuencode file2 file2;"
echo `( $LIST ) | mailx -s "test2" abc@abc.com`


Thank you
 
The second one should be...
[tt]
LIST="uuencode file1 file1; uuencode file2 file2"
echo $LIST | mailx -s "test2" abc@abc.com
[/tt]
I haven't tested it, but that should do it.

You need to be careful, because there may be a limit to how many bytes a variable can hold. Doing it this way assigns the output of both uuencodes to the variable LIST. If these are big files, it could bomb or truncate if it exceeds a variable size limit.

Hope this helps.

 
Oops, that should be...
[tt]
LIST="$(uuencode file1 file1)
$(uuencode file2 file2)"
echo $LIST | mailx -s "test2" abc@abc.com
[/tt]
Same warning as previous post.

Hope this helps.

 
Hello SamBones, thankyou for your help!

I have tried your code. I can receive the email after I execute the file. However I can just receive the unknown text but not my attachments...I guess the command UUENCODE may not be run...so what should I do? Sorry that I do not know Unix shell script very much~
 
Hello, one more thing I would like to tell is if I add #!/bin/sh at the beginning of the file, I can still send the email. but what I receive is just the string of "uuencode....", but not the binary attachment...
 
#!/usr/bin/sh
(uuencode file1 file1;uuencode file2 file2)>list
cat list |mailx -s "test2" huxu@cn.fujitsu.com


i'v tested this shell script,it works well

good luck!
 
Hi bluelake, nice to see u here again :)

Thank you for your help in heart again! I can send those attachments succesfully finally! I am so happy that there are so many web-friends to help solve my problem. I really appreciate it very much! May I thank SamBones, J1mbo and pmcmicha for your help too!
 
i am also glad i'v met you guys and my poor english can be understood.
i want to practise my english simultaneously when improving my technical skill.

there are so many kind person in this forum,they are real generous tech master.
:)




 
I know you have the solution, but here is the reason why the results are different. When you enclose a command in `back quotes` or in $() the trailing new-lines are replaced with spaces, e.g.
[tt]
$ echo 123 > file1
$ uuencode file1 file1
begin 644 file1
$,3(S"@``
`
end

$
[/tt]
This works fine, but when you use command substitution, e.g.
[tt]
$ echo `uuencode file1 file1`
begin 644 file1 $,3(S"@`` ` end
$
[/tt]
then you notice that the output from the uuencode command has no new-lines. This means that an email client cannot uudecode the message sucessfully, resulting instead in a email full of garbage with no attachments!

----Ygor
 
i am not sure what the groundrules are, but I would

LIST="uuencode file1 file1; uuencode file2 file2;"
( eval $LIST ) | mailx -s "test2" abc@abc.com

or
LIST="(uuencode file1 file1; uuencode file2 file2;)"
eval $LIST | mailx -s "test2" abc@abc.com`
 
Thanks all of you~
I have tried your commands too. They work normally. So now other than command substittution, I can try another command EVAL...that's the new onw I just learnt :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top