Why in perl system(" ") command, "source command_file" does nothing,but "source command_file && echo

K

Kuhl

Hi, in my Perl script,

system("source command_file");
does nothing.

But
system("source command_file && echo");
works correctly.

How come?

BTW, the command_file looks like below:

calibre -query << ! | tee log_file
filter layers lay_bond_pad
net shapes AGNDP
filter layers lay_bond_pad
net shapes DM
filter layers lay_bond_pad
net shapes DP
filter layers lay_bond_pad
net shapes VDD
!

This is using the soft ware Calibre Query Server of Mentor Graphics.

Thank you in advance.
 
T

Tad J McClellan

Kuhl said:
Hi, in my Perl script,

system("source command_file");
does nothing.


You should always enable warnings when developing Perl code.

But
system("source command_file && echo");
works correctly.

How come?


Because "source" is a shell built-in and the 1st call does not
invoke a shell (because it is a single arg with no shell metachars).

perldoc -f system


Either give system() a list of args that calls the shell you want:

system("/bin/sh", "-c", "source command_file");

or give system() a single arg that contains a shell metachar:

system("source command_file;");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top