For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > November 2004 > Perl call unix shell script









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Perl call unix shell script
linlin107

2004-11-24, 3:56 am

Hi,

I have a unix shell script like that:

.....
export username=scott
export password=tiger
....

I have a perl script call this shell script, and try to get the value of
username password and use in perl script.

Could you tell me how to do that?

Thanks,
Carl


Joe Smith

2004-11-24, 8:56 pm

linlin107 wrote:
> Hi,
>
> I have a unix shell script like that:
>
> ....
> export username=scott
> export password=tiger
> ...
>
> I have a perl script call this shell script, and try to get the value of
> username password and use in perl script.


unix% perldoc -q environment
Found in /usr/lib/perl5/5.8.3/pod/perlfaq8.pod
I {changed directory, modified my environment} in a perl script.
How
come the change disappeared when I exited the script? How do I
get my
changes to be visible?

Unix
In the strictest sense, it can't be done--the script
executes as a
different process from the shell it was started from.
Changes to a
process are not reflected in its parent--only in any
children cre-
ated after the change. There is shell magic that may allow
you to
fake it by eval()ing the script's output in your shell;
check out
the comp.unix.questions FAQ for details.
Tintin

2004-11-25, 8:56 am


"linlin107" <linlin107@rogers.com> wrote in message
news:pJWdnU9wysQXeT7cRVn-ig@rogers.com...
> Hi,
>
> I have a unix shell script like that:
>
> ....
> export username=scott
> export password=tiger
> ...
>
> I have a perl script call this shell script, and try to get the value of
> username password and use in perl script.
>
> Could you tell me how to do that?


$ENV{username}='scott';
$ENV{password}='tiger';

*However*, that leds me to think you are going to be doing Oracle SQL
queries.

Head on over to http://dbi.perl.org/


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com