471,853 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

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");
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.
am not able to sort this problem ??

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

Sep 23 '08 #1
3 7871
3,503 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.


Sep 23 '08 #2
174 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
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...

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
reply views Thread by NeoPa | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.