file redirection

Discussion in 'Perl Misc' started by paul_0403@yahoo.com, Oct 27, 2008.

  1. Guest

    I have a perl program that opens and writes to a logfile, this all
    works
    well.

    ie

    if (! open (LOG, ">>$logfile"))
    {
    print STDERR "Cannot open logfile $logfile $!\n";
    exit 1;
    }

    print LOG "Hello world\n"

    I want to redirect the outpuf of a system command ot the same
    log but I am having trouble getting it to work.

    Can I do something like this? If not, how can I get this to work.
    system("kill -USR1 \"$1\" > LOG 2>\&1");

    When I issue this command on the command line I get a permissions
    problem. When I run it from the perl script I was expecting to see the
    same permssion problem in my log file.

    THanks to all who answer
    , Oct 27, 2008
    #1
    1. Advertising

  2. writes:

    > I have a perl program that opens and writes to a logfile, this all
    > works
    > well.
    >
    > ie
    >
    > if (! open (LOG, ">>$logfile"))
    > {
    > print STDERR "Cannot open logfile $logfile $!\n";
    > exit 1;
    > }
    >
    > print LOG "Hello world\n"
    >
    > I want to redirect the outpuf of a system command ot the same
    > log but I am having trouble getting it to work.
    >
    > Can I do something like this? If not, how can I get this to work.
    > system("kill -USR1 \"$1\" > LOG 2>\&1");
    >
    > When I issue this command on the command line I get a permissions
    > problem. When I run it from the perl script I was expecting to see the
    > same permssion problem in my log file.


    You really should read the answers given before you re-post your
    code in a slightly different (but still misguided) form.



    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
    Joost Diepenmaat, Oct 27, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    7
    Views:
    388
    Herbert Rosenau
    Aug 2, 2006
  2. TP
    Replies:
    2
    Views:
    317
  3. Rohit Srivastava

    File System Redirection Windows x 64 box.

    Rohit Srivastava, May 15, 2009, in forum: Python
    Replies:
    2
    Views:
    689
    Dave Angel
    May 15, 2009
  4. Gennady
    Replies:
    0
    Views:
    183
    Gennady
    Jun 28, 2003
  5. James T Kirk
    Replies:
    2
    Views:
    137
    James T Kirk
    Aug 21, 2003
Loading...

Share This Page