开发者

Devise script command utility with one simple line command

The script utility works like this:

$ script
Script started, file is typescript
$ ls
2           bin         doubleline  new1        play        typescript
alok        core        filelist    output      pslist      unix
$ ps
   PID TTY开发者_运维百科      TIME CMD
 28149 pts/7    0:00 ksh.ms
$
Script done, file is typescript

After this contents of the typescript file are:

$ cat typescript
Script started on Wed Sep 07 05:56:26 2011
$ ls
2           bin         doubleline  new1        play        typescript
alok        core        filelist    output      pslist      unix
$ ps
   PID TTY      TIME CMD
 28149 pts/7    0:00 ksh.ms
$

script done on Wed Sep 07 05:56:33 2011

$

I want to copy this behaviour with using other commands and I/O redirections. The solution must be a one line command (may include pipelined commands).

Any help would be great, like if anyone can tell how can we redirect stdin, stdout and stderr to some file while all the data is still on the terminal.


$tee -a typescript | sh -i 2>&1 | tee -a typescript
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜