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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl and subshell command with variable

Status
Not open for further replies.

lpmartineau

Technical User
Dec 20, 2004
26
CA
Hi everyone,

I am trying to run a mailx command to send an email (all internal, server does not talk to the outside world)

It is not passing the Variable in the subject of the email.

Code:
system('mailx -s "[CLOSE#$line]" -r "user@domain.com" user@domain.com stamp.txt');

$line is a variable that works and I have tried to just print the variable and it works just fine.

I also tried:
Code:
system('mailx -s "CLOSE#'$line'" -r "user@domain.com" luma@domain.com < stamp.txt');

any suggestions?

I am new to perl and been at this for hours now and starting to go nuts :)

Thank you

Luma
 
system('mailx -s "[CLOSE#$line]" -r "user@domain.com" user@domain.com stamp.txt');

to

system("mailx -s \"[CLOSE#$line]\" -r \"user\@domain.com\" user\@domain.com stamp.txt");

I would just mailx to the full path to mailx (/usr/bin/mailx or what ever.. if you don't know do a whereis mailx)

but.. I would suggest looking at some of the Mail modules to send email instead of shelling out to do it. It makes your life a lot easier once you figure them out.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
ya I really should figure out and use the module.

I tried what you suggested and it did not work either:
Code:
 system('mailx -s \"[CLOSE#$line]\" -r \"user@domain.com\" luma\@domain.com < stamp.txt');

gave me an email with a subject of "[CLOSE#]" with a reply to address of "user@domain.com"
quotes and all :)

Thanks again I do appreciate it.

Luma
 
You changed the code travs69 recommened you try. At least the code you posted is not the same. Use the exact code he posted and try again.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
ahh I see my mistake, sorry my eyes just did not see it the first couple times I looked at it.

am going to go try it.

thanks

Luma
 
It works!

stupid single/double quotes :p

It works like a charm now!

Thank you very much!

Have a great weekend.

Luma
 
Yeah.. them quotes will get you. I would still change mailx and your file to full path's though. It will come back to haunt you if you don't get into that habit.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top