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, --contains:
Expand|Select|Wrap|Line Numbers
  1. system(perl -f  -t -s -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, i get this error :
Expand|Select|Wrap|Line Numbers
  1. C:\sendEmail-v1.55>perl
  2. Array found where operator expected at line 1, at end of line
  3. Array found where operator expected at line 1, at end of line
  4. syntax error at line 1, near "pl -f "
  5. Execution of 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
Share this Question
Share on Google+
3 Replies

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 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

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 -f -t -s -u "Test Mail" -m "Test Mail");
try this:

Expand|Select|Wrap|Line Numbers
  1. system(`perl -f -t -s -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 code.

also on another note: have you read the other post you posted
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 helps all perl newbie's...

ahhh icecrack.. i have seen the other post which u have 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.