file redirection

P

paul_0403

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
 
J

Joost Diepenmaat

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.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top