By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,811 Members | 1,978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,811 IT Pros & Developers. It's quick & easy.

how to run the perl script by passing it's arguments using system ??

P: 65
Hi all,

i have perl script, which is used to send mail. its a command line utility.
if we run this perl script in command line by passing all it's required arguments, it works very well.there no issues.

my problem is :
am just call this perl script by using "system" command inside the another perl script. ie,

mail.pl --contains:
Expand|Select|Wrap|Line Numbers
  1. system(perl sendEmail.pl -f bbb.aaa@ccc.co.uk  -t aaa.ddd@eee.co.uk -s aaabbbcc.ddd.com -u "Test Mail" -m "Test Mail");
  2.  
here arguments stands for:

-t ADDRESS [ADDR ...] to email address(es)
-u SUBJECT message subject
-m MESSAGE message body
-s SERVER[:PORT] smtp mail relay.

when i try to run mail.pl, i get this error :
Expand|Select|Wrap|Line Numbers
  1. C:\sendEmail-v1.55>perl mail.pl
  2. Array found where operator expected at mail.pl line 1, at end of line
  3. Array found where operator expected at mail.pl line 1, at end of line
  4. syntax error at mail.pl line 1, near "pl -f "
  5. Execution of mail.pl aborted due to compilation errors.
  6.  
am not able to sort this problem ??

am using Win2k OS & Activestate V5.10.0 perl.
can any one help me out this ????

Regards,
Vijayarl
Sep 23 '08 #1
Share this Question
Share on Google+
3 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
You are going to really run into a lot of syntactical issues calling that the way that you are. My suggestion would be to convert your sendmail.pl script into your own internal module that you can include in your script(s) and call the code as a function with all the necessary options. It would be a cleaner way to do it, especially since it appears this will not be a one-off solution, but instead used over and over.

Regards,

Jeff
Sep 23 '08 #2

Icecrack
Expert 100+
P: 174
First off, i agree with numberwhun on that point,

second your getting errors because,

Expand|Select|Wrap|Line Numbers
  1. system(perl sendEmail.pl -f bbb.aaa@ccc.co.uk -t aaa.ddd@eee.co.uk -s aaabbbcc.ddd.com -u "Test Mail" -m "Test Mail");
try this:

Expand|Select|Wrap|Line Numbers
  1. system(`perl sendEmail.pl -f bbb.aaa@ccc.co.uk -t aaa.ddd@eee.co.uk -s aaabbbcc.ddd.com -u "Test Mail" -m "Test Mail"`);
you forgot to cancel the @, - .... etc.

also i think to help you find problems we will need a print out of sendEmail.pl code.


also on another note: have you read the other post you posted
http://bytes.com/forum/thread839929.html
Sep 23 '08 #3

P: 65
Hi Jeff/Icecrack,

Thanks for your valueable suggestions.

i used icecrack 1st solution, it worked :-)

really, i would love to takeup jeff idea & implement..since am runningout of time..
i had to choose other one...

anyway's thanks guys for your help & support..your doing great work..!!!
please keep going..it helps all perl newbie's...

ahhh icecrack.. i have seen the other post which u have replied..am still not yet tried that one...

Bye
Vijayarl
Sep 24 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.