system command question

Hi,
I am trying to run a make file from perl. For the make file to run,
some environment variables need to be set. Usually I would use a batch
file with the following setting
SET A_DIR=C:\TOOLS\TMS320
SET C_DIR=C:\TOOLS\TMS320
PATH=%PATH%;C:\TOOLS;C:\TOOLS\TMS320
make

and it works.

I tried to do this in perl using a system call but it failed
system("SET A_DIR=C:\\TOOLS\\TMS320 & SET C_DIR=C:\\TOOLS\\TMS320 &
PATH=\%PATH\%;C:\\TOOLS;C:\\TOOLS\\TMS320 & make >
compilation_output.txt");

Any idea why the system command is not setting the path and A_DIR and
C_DIR correctly.

Thanks,
Amish


--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Amish Rughoonundon [ Di, 27 September 2011 22:43 ] [ ID #2064945 ]

RE: system command question

> -----Original Message-----
> From: Amish Rughoonundon [mailto:amishrughoonundon [at] gmail.com]
> Sent: Tuesday, September 27, 2011 4:44 PM
> To: beginners [at] perl.org
> Subject: system command question
>
> Hi,
> I am trying to run a make file from perl. For the make file to run,
> some environment variables need to be set. Usually I would use a batch
> file with the following setting
> SET A_DIR=C:\TOOLS\TMS320
> SET C_DIR=C:\TOOLS\TMS320
> PATH=%PATH%;C:\TOOLS;C:\TOOLS\TMS320
> make
>
> and it works.
>
> I tried to do this in perl using a system call but it failed
> system("SET A_DIR=C:\\TOOLS\\TMS320 & SET C_DIR=C:\\TOOLS\\TMS320 &
> PATH=\%PATH\%;C:\\TOOLS;C:\\TOOLS\\TMS320 & make >
> compilation_output.txt");
>
> Any idea why the system command is not setting the path and A_DIR and
> C_DIR correctly.
>
> Thanks,
> Amish
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
> For additional commands, e-mail: beginners-help [at] perl.org
> http://learn.perl.org/
>
The system call spawns a separate process, so the environment variables will
be set in the spawned process only.
Try setting these environment variables through the %ENV hash which contains
the current environment.
Ken



--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Ken Slater [ Mi, 28 September 2011 13:02 ] [ ID #2064947 ]
Perl » gmane.comp.lang.perl.beginners » system command question

Vorheriges Thema: Need help getting data from a structure..
Nächstes Thema: Can't use string ("1") as a HASH ref while "strict refs"