pijush has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!

I am facing a problem to execute a command using system. I have written following script to copy a file from ClearCase.

mkdir ("xxxx",0755); #xxxx has the absolute path system ("clt setview zzzzz-view; \`cp /vobs/qa/common/yy.txt xxxx\`") +; print "Copy has completed successfully\n";
In the above code what clt setview is doing it is setting a view, but it also spawns a new child shell and from the child shell /vobs/qa/common/yy.txt file is visible, but not from the parent shell. So the above script fails to copy yy.txt file. I have also tried with following command.
system (". clt setview zzzzz-view; \`cp /vobs/qa/common/yy.txt xxxx\` +");
But it is giving error. Can anybody please tell me how can I execute copy command in child shell instead of the parent shell?
Any help really appreciated.
Thanks in advance.
Regards
-Pijush

Replies are listed 'Best First'.
Re: How to execute command in child shell from parent shell?
by Abigail-II (Bishop) on Jan 05, 2004 at 16:39 UTC
    What are those backticks doing in the command? You're telling the shell execute the cp command, and to execute whatever the cp command writes to STDOUT (which is probably not much).

    What do you mean by the file "not be able to be seen"? You give a full path to the file, so it can't be a working directory issue.

    Finally, whether or not you can execute a command from the shell started by clt, and if, how, is something that the manual page of clt might be able to tell you. But it's not a Perl issue (and neither is it a Unix issue).

    Abigail

      Thanks Abigail-II.
      I got the solution from your pointer. I used the back cote inside the system command, to run cp command which is the shell command, not the perl command.
      I have found that there is -exec command which can be used to copy a file or directory and I am using this.
      Thanks again.
      -Pijush