Running a command as a user(perl)

d4mo

Senior member
Jun 24, 2005
588
0
0
I'm making an email script. I'm using perl to do a couple of things and then send an email using ssmtp. The problem is when I run the ssmtp command I don't think it's running as me. How can I get it to run as me(or any user for that matter)?

I'm using system("ssmtp email@email.com < asdfsda.txt");

When perl runs that what user is technically running the ssmtp command? I assume it's not getting my user config and thats why it's not going through.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,835
4,815
75
I would expect that Perl is working under your username. Try the following at a terminal to find out for sure:

perl -e "print `whoami`"

There are three ways to run a system command in Perl: the way you did it, the way I just did above, and open with a pipe. I suggest you try:

open(IN, "ssmtp email@email.com < asdfsda.txt |");

and see what the output is, if any.
 

d4mo

Senior member
Jun 24, 2005
588
0
0
Thats really weird. It does run as me. But here's the thing. I did a ssmtp -v(verbose) and it claims the message was sent right. Everything is identical(output) if I do it from the from the shell or from through the perl program, only when I do it through perl the email never gets to my inbox.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,835
4,815
75
Yes, that is weird.

Well, there's always Net::SMTP. Have you ever installed anything with CPAN before?
 

d4mo

Senior member
Jun 24, 2005
588
0
0
Yeah, I could use stuff from CPAN but now I just want to know why it doesn't work. I installed mailx and the same thing happens :S