passing arguments to a shell script from a perl script - Perl
This is a discussion on passing arguments to a shell script from a perl script - Perl ; Hi,
Is there anyway can I pass arguments to a shell (bash) script from
within a perl script and execute the shell script.
The reason I want to call a shell script is that I want to export
environmental variables. ...
-
passing arguments to a shell script from a perl script
Hi,
Is there anyway can I pass arguments to a shell (bash) script from
within a perl script and execute the shell script.
The reason I want to call a shell script is that I want to export
environmental variables. Since, we can't do it from a perl script, I
wanted to write the environmental variables in a shell script and
execute it.
Can anyone let me know how can I do this in perl.
Thanks,
doni
-
Re: passing arguments to a shell script from a perl script
Hi
You can actually actually indeed do this from within a perl script.
You can also set environment variables from within perl. I'm sure
you will get a few responses on this one as there are various ways,
the simplest way would be to do:
______________
my $script_to_execute = "script_name" ;
my $parameters = "one two three" ;
my $shell_call = $script_to_execute . " $parameters" # note the
space
system($shell_call)
______________
Hope the above helps.
cheers
--
--------------------------------- --- -- -
Posted with NewsLeecher v3.9 Beta 6
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -
-
Re: passing arguments to a shell script from a perl script
On Dec 7, 2:44 pm, doni <doni.se...@gmail.com> wrote:
> Hi,
>
> Is there anyway can I pass arguments to a shell (bash) script from
> within a perl script and execute the shell script.
>
> The reason I want to call a shell script is that I want to export
> environmental variables. Since, we can't do it from a perl script, I
> wanted to write the environmental variables in a shell script and
> execute it.
>
> Can anyone let me know how can I do this in perl.
>
> Thanks,
> doni
Code called by system inherits the perl environment.
Try this:
perl -e '$ENV{PATH} .= ":/new/path"; system "echo \$PATH";'
-
Re: passing arguments to a shell script from a perl script
On Fri, 07 Dec 2007 11:44:57 -0800, doni wrote:
> Hi,
>
> Is there anyway can I pass arguments to a shell (bash) script from
> within a perl script and execute the shell script.
>
> The reason I want to call a shell script is that I want to export
> environmental variables. Since, we can't do it from a perl script, I
> wanted to write the environmental variables in a shell script and
> execute it.
Just set values in %ENV and your child process will inherit them. No need
for this complicated workaround.
HTH,
M4
-
Re: passing arguments to a shell script from a perl script
aaah wrote:
> Hi
>
> You can actually actually indeed do this from within a perl script.
> You can also set environment variables from within perl. I'm sure
> you will get a few responses on this one as there are various ways,
> the simplest way would be to do:
> ______________
> my $script_to_execute = "script_name" ;
> my $parameters = "one two three" ;
> my $shell_call = $script_to_execute . " $parameters" # note the
> space
>
> system($shell_call)
> ______________
You're not doing anything with the environment other than passing it
along implicitly.
You'd have to modify %ENV.
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
Similar Threads
-
By Application Development in forum Perl
Replies: 5
Last Post: 12-13-2007, 07:17 PM
-
By Application Development in forum Perl
Replies: 0
Last Post: 11-02-2007, 08:03 PM
-
By Application Development in forum Javascript
Replies: 3
Last Post: 09-04-2007, 09:58 AM
-
By Application Development in forum Perl
Replies: 0
Last Post: 05-31-2007, 08:03 AM
-
By Application Development in forum Graphics
Replies: 1
Last Post: 09-29-2006, 02:33 PM