you will have to forgive me on my naivety here...
I think ( not certain ) script works in the same way as a shell, but sending stdin to both stdout and a file and not just stdout
when you pipe to logger, logger takes stdout and sends to file ( syslog )
I believe it may in the long run be easier to modify script's source to send direct to syslog as well as it's normal behaviour.
I have not yet looked at the source, but I imagine it would be relatively straight forward
however, had a little play and came up with this
Code:
touch typescript # probably don't need
( tail -f typescript | logger ) &
script -f
the -f for script flushes to script's logfile (typyscript here) each write
tail 'follows' typescript, piping to logger
the downside is some of the output are 'odd'
'shell'
Code:
$ script -f
tail: typescript: file truncated
Script started, file is typescript
firerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ echo "testing one two three"
testing one two three
firerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ sleep 2
firerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ for i in {1..4};do sleep $i;echo slept 1 second;done
slept 1 second
slept 1 second
slept 1 second
slept 1 second
firerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ exit
syslog
Code:
Sep 12 19:19:22 Ab9Pro firerat: Script started on Thu 12 Sep 2013 19:19:22 BST
Sep 12 19:19:29 Ab9Pro firerat: #033]0;firerat@Ab9Pro: /home/firerat/LinuxQ/LogScript#007firerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ echo "testing one two three"#015
Sep 12 19:19:29 Ab9Pro firerat: testing one two three#015
Sep 12 19:19:56 Ab9Pro firerat: #033]0;firerat@Ab9Pro: /home/firerat/LinuxQ/LogScript#007firerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ sleep 2#015
Sep 12 19:20:52 Ab9Pro firerat: #033]0;firerat@Ab9Pro: /home/firerat/LinuxQ/LogScript#007firerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ for i in sle#010#033[K#010#033[K#010#033[K{1,2,3#010#033[K#010#033[K#010#033[K#010#033[K#010#033[K#010#033[K#010#033[K#010#033[Kn {1..4};do sleep $i;echo slpet#010#033[K#010#033[K#010#033[Kept 1#010#033[K1 second;done#015
Sep 12 19:20:53 Ab9Pro firerat: slept 1 second#015
Sep 12 19:20:55 Ab9Pro firerat: slept 1 second#015
Sep 12 19:20:58 Ab9Pro firerat: slept 1 second#015
Sep 12 19:21:02 Ab9Pro firerat: slept 1 second#015
Sep 12 19:21:08 Ab9Pro firerat: #033]0;firerat@Ab9Pro: /home/firerat/LinuxQ/LogScript#007firerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ exit#015
Sep 12 19:21:08 Ab9Pro firerat: exit#015
Sep 12 19:21:08 Ab9Pro firerat:
Sep 12 19:21:08 Ab9Pro firerat: Script done on Thu 12 Sep 2013 19:21:08 BST
you can see me 'fixing' my rethinks and typos
I guess you could have sed between tail and logger, to make them readable
'raw' typescript file
Code:
Script started on Thu 12 Sep 2013 19:19:22 BST
^[]0;firerat@Ab9Pro: /home/firerat/LinuxQ/LogScript^Gfirerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ echo "testing one two three"^M
testing one two three^M
^[]0;firerat@Ab9Pro: /home/firerat/LinuxQ/LogScript^Gfirerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ sleep 2^M
^[]0;firerat@Ab9Pro: /home/firerat/LinuxQ/LogScript^Gfirerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ for i in sle^H^[[K^H^[[K^H^[[K{1,2,3^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[K^H^[[Kn {1..4};do sleep $i;echo slpet^H^[[K^H^[[K^H^[[Kept 1^H^[[K1 second;done^M
slept 1 second^M
slept 1 second^M
slept 1 second^M
slept 1 second^M
^[]0;firerat@Ab9Pro: /home/firerat/LinuxQ/LogScript^Gfirerat@Ab9Pro:/home/firerat/LinuxQ/LogScript$ exit^M
exit^M
Script done on Thu 12 Sep 2013 19:21:08 BST
another downside is you need to clean up ( tail -f typescript | logger ),
you could get the PID of it with $!, and then kill it once script exits
ultimately, I think modifying script's source code, adding a log to syslog flag is the cleanest
edit:
prompted by unSpawn's post, I did
Code:
cat typescript
cat typescript
inside the script shell
it then 'took over' with a nasty loop, filling syslog