Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

piping

Status
Not open for further replies.

izivt

Programmer
Jun 26, 2001
17
US
I am having trouble piping the output of the "at" command to my program.
it seems that it would work just like any function, but for some reason it does not output the info to STDOUT.

ie.

this works well..
##################

open(ATQ, "atq|");
while(<ATQ>)
{
print $_;
}

##################
but..
###################
open(AT, &quot;at -f commands 00:00 12/12/01 |&quot;); #&quot;commands&quot; is the file with the commands so that the program does not need to be interactive
while(<AT>) #says that it's already closed
{
print $_; #prints nothing
}
###################
does not. The output, which is supposedly should have been in the $_ variable is just outputed into the console as if I just opened the command without piping.

i.e &quot;job 40 00:00 2001-12-12 a&quot; or something of that sort

if anyone has an idea of why it would do that and how to go around the problem, I would be very greatfull.
 
is it plausible that the &quot;at&quot; command actually calls on something else which eventually prints the final verifications?.. hmmm.. how would I be able to go around that and get the output?
 
izivt

I am not a perl programmer in any way shape or form, but just a suggestion which may help.

When used in the way you have the at command submits the at-job and writes scheduled time and at-job-id to standard error, not STDOUT.

In order to capture standard error as well as STDOUT use |& not simply | - if this is permitted in perl. As I say, I'm not a perl programmer, I just seem to have got lost.

Hope this helps.

MB.
 
that make sense. hmm.... I have tried a couple of syntaxes, but unfortunatly, I am not sure what the correct one is either.
 
izivt

Try this.

Code:
open(AT,&quot;at -f command 00:00 12/12/01 2>&1 |&quot;);

MB
 
Thank you very much mubman. That definitely did work. The funny part is that I actually tried that, but I reversed the 2>&1 and |, which I didn't realize was wrong. Thank you!! :)



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top