But! sometimes it's not possible to capture output of some Apps.
SSH is a good sample. I tried to capture a complete output of an
ssh session but it was not possible! when you are trying to do an
ssh for the first time, it will shows a message like this:
And, this message couldn't be captured!
I would be surprised if you couldn't capture this....have you tried something like "script" ? That seems to capture my ssh sessions fine...
If that captures it, then anything can (cos it doesnt run setuid)
BTW, There are oddities that you have to be aware of, for example if you have:
The "more" command throws up a prompt onto the users screen, and waits for the user to press a key. This obviously isnt from stdin (as it takes that from the cat /tmp/foo). Actually what the shell does is to pass the stderr to the "more" command and the more command checks to see if that is attached to a tty and then does its input/output through that....but thats another story)
Although its theoretically possible for programs to open /dev/tty, this is almost never done by useful applications. This is because the shell would normally be in control of the tty, and uses it for job control. If another program opened /dev/tty and started trying to do I/O through it, the shell would probably quit out or get arsey.
I hope this makes things a little clearer
---------- Post updated at 11:48 PM ---------- Previous update was at 11:35 PM ----------
Yep, looking at script, it allocates a new pseudoterminal (pty), which pretends to be the logged in users tty. This is the same as "expect", and indeed exactly the same method that sshd and telnetd use to emulate terminals. If you look at the code to expect or script (or indeed sshd) you will see their method of allocating pty's and from there you can do interactive I/O to any process, even the ones, like passwd, that insist on a controlling pty.
---------- Post updated 01-26-11 at 12:03 AM ---------- Previous update was 01-25-11 at 11:48 PM ----------
(BTW, I just noticed your original question contained the sentence "I have a simple question about I/O redirection. "....So, I apologise for my over complicated answer...I realise now that it probably wasn't what you were after...)
hi everybody,
when i run and compile this:
printf("test"); fflush(stdout);
nothing appears on screen.
if i try this:
___________________________________
printf("test"); fflush(stdout); sleep(10);
___________________________________
then i can see the output "test"... for 10... (4 Replies)
Hi,
I see from lsvg the total used PPs is 1050 (67200 megabytes), but when I check the disk space with df command I can only see 31G total space, can somebody tell how this come?
Thanks!
Victor
# lsvg
rootvg
# lsvg rootvg
VOLUME GROUP: rootvg VG IDENTIFIER: ... (2 Replies)
Is it possible to store all standard-out of a bash script and the binaries it calls in a log file AND still display the stdout on screen?
I know this is possible to store ALL stdout/stderr of a script to a single log file like:
exec 1>&${logFile}
exec 2>&1
But running a script with the... (3 Replies)
Dear Member,
OLD Question --> disable-completion not solved
My bash Menu script ping process problem.
If ping still running and users press SCREEN is Blank...
Cant Members help me.. kill signal or others scripting for my case, btw i use Linux..
Thanks,
Rico
My Bash Script :
... (1 Reply)
I am unable to use clear or cls command on bash shell. I have recently installed Cygwin and am using that for practicing unix commands.
I see that I can use Ctrl + L to clear the screen. I created an alias in my .bashrc to do the same as
alias cls='^L'
This is how i defined other aliases ... (4 Replies)
Hi all,
How to:
Run a bash script, display on the screen and save all information in a file including error information.
For example:
I have a bash script called test.sh
now I want to run the test.sh and display the output on the screen and save the output including error info to a file.
... (1 Reply)
The block size in my home directory is showed wrong when I use "quota" command. It shows I use 1.2 gb ( about 1200000) while the real size in my directory which I use "du" command is 96 MB
I really confused. (0 Replies)
Hello, everyone. I'm currently trying to write a command system for a Minecraft server using screen.
Here are the scripts I'm currently using.
0.sh
#!/bin/bash
screen -S Test114 -dm java -Xmx4G -jar server.jar nogui
1.sh
#!/bin/bash
args="$@"
args2="${args@Q}"
#args3=`printf '%q\n'... (2 Replies)