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

hello guys , I have this command , and would like direct the output to a file chdir 'w:' or die "couldn't chdir ($!)"; system (qw(build -sdcdd), $ss, "-sbc")); I want somehow to direct the output from the system command to a file under my current drive not the w: drive , I have to excute the command under w: but he output should be under my current any ideas or tips ,, thanks

Replies are listed 'Best First'.
Re: System command
by thunders (Priest) on Jul 08, 2002 at 19:40 UTC

    ok so you change your directory issue a system command and you want the output to go somewhere other than the current directory?

    I see two options

    1. if your build program has a command line option where you can change the name of the output directory you can use the Cwd module to capture the name of the starting directory and save it in a varible, then use that as a parameter to build. I don't know of "build" so i can't say if this is possible.
    2. If you know what the name of the output file will be use File::Copy to send that output file wherever you want after it has been created.
Re: System command
by arfeen (Initiate) on Nov 02, 2007 at 18:53 UTC
    im running a system command in my cgi file. the script is very simple. i want to start a service im using 2 ways @args = ("service","ipsec","restart"); system(@args) and system("service ipsec restart"); none of them is working. while it works on the shell successfully. please let me know.