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. Advertisements

  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. Advertisements

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. MadHatter

    input redirection

    MadHatter, Oct 14, 2003, in forum: Perl
    Replies:
    6
    Views:
    859
    MadHatter
    Oct 16, 2003
  2. S
    Replies:
    1
    Views:
    957
  3. Replies:
    7
    Views:
    546
    Herbert Rosenau
    Aug 2, 2006
  4. TP
    Replies:
    2
    Views:
    438
  5. Rohit Srivastava

    File System Redirection Windows x 64 box.

    Rohit Srivastava, May 15, 2009, in forum: Python
    Replies:
    2
    Views:
    790
    Dave Angel
    May 15, 2009
  6. Gennady
    Replies:
    0
    Views:
    294
    Gennady
    Jun 28, 2003
  7. James T Kirk
    Replies:
    2
    Views:
    208
    James T Kirk
    Aug 21, 2003
  8. file redirection

    , Oct 27, 2008, in forum: Perl Misc
    Replies:
    3
    Views:
    167
    John W. Krahn
    Oct 27, 2008
Loading...