1833689 Members
3843 Online
110062 Solutions
New Discussion

Redirect STDIN

 
Ollie R
Respected Contributor

Redirect STDIN

Hi,
Using OpenSSH, I connect from one system, called BASTION, to another system, called TARGET.
I wish to record the commands entered at the keyboard while connected to TARGET into a file on BASTION. That is, I wish to record STDIN only, without STDOUT.
Does anyone know how I can achieve this?
Thanks!
To err is human but to not award points is unforgivable
8 REPLIES 8
Karthik S S
Honored Contributor

Re: Redirect STDIN

Try,

ssh TARGET | tee target.out

Regards,
Karthik
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Ollie R
Respected Contributor

Re: Redirect STDIN

Thanks, but that also does STDOUT. I don't want STDOUT as I'm trying to produce a history of commands typed only.
To err is human but to not award points is unforgivable
Massimo Bianchi
Honored Contributor

Re: Redirect STDIN

Hi,
and if you enable history on the TARGET you should get what you want.

For example, putting HISTFILE and EDITOR variables in .profile.

If you wish to keep track of command, you can also personalize the name of the history file for each connection,
export HISTFILE=$HOME/.sh_history`tty|tr / _`


HTH,
Massimo
Ollie R
Respected Contributor

Re: Redirect STDIN

Thanks, but I wish to record the STDIN on BASTION, not TARGET.
To err is human but to not award points is unforgivable
Jean-Louis Phelix
Honored Contributor

Re: Redirect STDIN

Hi,

Did you try 'tee file | command' (ie tee /tmp/a | remsh hostname). It works, but I can't avoid echoing of all commands ...

Regards.
It works for me (© Bill McNAMARA ...)
John Meissner
Esteemed Contributor

Re: Redirect STDIN

This won't save the output to Bastion but it will save all Std in and out on Target

script

This will record everything done - input and output.
you could then ftp it to bastion if you wanted to
All paths lead to destiny
Caesar_3
Esteemed Contributor

Re: Redirect STDIN

Hello!

The best for your problem is to use
the "script" command so you will see the
whole input in the file!
You can also use the command | tee logfile
But script better.

Caesar
Caesar_3
Esteemed Contributor

Re: Redirect STDIN

Hello again!

You can also use tee -a filename to
take the stdin

Caesar