You could use the pipe open() of Perl as showed by Greg.
(see perldoc perlopentut, perldoc perlipc)
However, if you cannot trust the caller's input I would either
do a forking open with untainting in the child's block,
or rather use modules like Mail::Send or Mail::Mailer etc. http://search.cpan.org/~markov/MailT...4/Mail/Send.pm
You are obviously mixing shell and Perl variables here.
Generally you should avoid this mixture because Perl is powerful enough
to get rid of all shell escapes, and Perl has built-ins of almost all Unix syscalls
which render them completely redundant.
Not only degrades this the performance of your Perl program
(though this is seldom an issue for the quick and dirty hack),
but it also makes your programs more insecure,
which indeed is relevant for e.g. CGIs or server programs.
(n.b. if you can afford the time you should read perldoc perlsec )
But if you are reluctant to rewrite your shell script wrapper into your Perl code
then you could either pass shell variables to the called Perl script
e.g.
or you could access the shell variables via the %ENV hash,
provided you export them in your shell wrapper script
e.g.
I have create this shell script
#!/bin/sh
if ; then
echo "Usage: ./script <filename>"
exit 1
elif ; then
fname="$1"
fi
output="output.txt"
i=0 ... (11 Replies)
Gents,
I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Hi all,
I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first.
Can you please help me determine which one to... (14 Replies)
Hi All,
Need help configuring Active Perl on Windows Vista.
I am trying to install Active Perl on Windows Vista.
The version of Active Perl i am trying to install is : ActivePerl 5.10.1 Build 1006
After installing it through cmd, When i try to run perl -v to check the version, i get the... (2 Replies)
Hi
How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Hi,
To run a perl script i am giving command like this in DOS prompt
d:> perl D:\<dir_name>\<dir_name>\sample.pl
Its throwing the following error while running the above
syntax error at <eval 4> line 1, near "use D:"
Can anyone help? (3 Replies)