Preventing shell redirection from creating empty file
From: Dan Fish (daf_at_ninemoons.com)
Date: 10/27/04
- Next message: Thomas Bätzler: "RE: using 'my' problem"
- Previous message: Dan Fish: "RE: Determine the Binary format of a file"
- Next in thread: Chris Devers: "Re: Preventing shell redirection from creating empty file"
- Reply: Chris Devers: "Re: Preventing shell redirection from creating empty file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: "Perl Beginners List" <beginners@perl.org> Date: Tue, 26 Oct 2004 22:25:55 -0700
I appologize that this is more of a shell question (tcsh) than a perl
question, but I've found that most of the really good perl guru's are fairly
decent shell wizards as well :-)
I have a c-routine that calls a perl script something like this:
system("myscript.pl arg1 arg2 > myfile.txt");
What is the easiest way to prevent "myfile.txt" from being created if the
script dies or produces no output? (It seems the shell will always create
myfile.txt, regardless)
I can think of a couple of ways offhand...
1. Within the c-routine, check for an empty file after the script is run
and remove if empty.
2. Handle the output directly from within the perl script with
open/print/close (I.E. avoid redirection)
I was hoping some shell guru out there knows a more generic approach.
Thanks,
-Dan
--- Dan Fish - seadancr@cox.net "A -good- dive buddy will be there if you run out of air, a -great- one will be there before you run out!"
- Next message: Thomas Bätzler: "RE: using 'my' problem"
- Previous message: Dan Fish: "RE: Determine the Binary format of a file"
- Next in thread: Chris Devers: "Re: Preventing shell redirection from creating empty file"
- Reply: Chris Devers: "Re: Preventing shell redirection from creating empty file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|