Hello Monks!
I am building a script that sets up our servers from a basic install to the correct settings. I have to send this output to an IQ (installation qualification) file.
This works very well until I get to the point where I do an update from RedHat and the RedHat script requires user input whether or not to continue.
When run without the STDOUT tee the question shows up ok. However when STDOUT uses the tee it does not.
Here is my code:
open (STDOUT, "|tee /var/tmp/IQOQ.txt");
&y_up; ##run yum update
sub y_up {
my $y = "/usr/bin/yum";
my $u = "update";
system("$y", "$u");
And here is the output and where it stops with the above code
Transaction Summary
======================================================================
+==========
Install 3 Package(s)
Update 67 Package(s)
Remove 0 Package(s)
Here is the output with the STDOUT code commented:
Transaction Summary
======================================================================
+==============================
Install 3 Package(s)
Update 67 Package(s)
Remove 0 Package(s)
Total download size: 114 M
Is this ok [y/N]:
How can I set this up so that the required user input is available?
Thanks Monks!
Update!
Thanks to all of you that answered. Some notes to the answers: Yes I could use the -y flag but management wanted to keep that part flexible.
I thought about the STDERR but never got around to trying it.
@Marshall-that may have worked but again I didn't get around to trying it.
In the end what I did was this:
close STDOUT; #close the original STDOUT tee to file
open (STDOUT, ">/dev/tty"); #open STDOUT back to just the terminal
system("$y", "$u");
#my $rhup = `"$y" "$u"`;
my $err = $?>> 8;
open (STDOUT, "|tee -ai /var/tmp/IQOQ.txt"); #Now re-tee STDOUT since
+ we aren't done
I did it like this as yum prints it's out put to /var/log/yum.log and I can get the list of updates from there. All I need for the IQOQ is to know whether or not it successfully completed which I do capture.
Thank you everyone for your help!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.