467,179 Members | 1,245 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,179 developers. It's quick & easy.

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

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
  • viewed: 7695
Share:
3 Replies
numberwhun
Expert Mod 2GB
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+
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
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.

Similar topics

6 posts views Thread by Robert Rozman | last post: by
52 posts views Thread by Olivier Scalbert | last post: by
reply views Thread by Kirt Loki Dankmyer | last post: by
6 posts views Thread by =?iso-8859-1?q?Luis_M._Gonz=E1lez?= | last post: by
1 post views Thread by rahulthathoo | last post: by
3 posts views Thread by coolheadash | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.