It is currently Tue Nov 24, 2015 8:12 pm

Piping the "script" command through the logger command.

All times are UTC - 6 hours

Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Thu Sep 12, 2013 11:00 am   

Joined: Mon Apr 27, 2009 2:24 pm
Posts: 10
I use the snippet below in /etc/profile on RHEL Linux to capture command line logging and it all works well and good.

Now I'd like to pipe the same output from script through the logger command so it all gets logged to syslog.

The only additional code I've added is in bold below (| bin/logger).

This works as expected sans one issue, albeit a major one. My terminal session is blank as if nothing is being typed, however if I type commands I can see them being logged and if I type exit my session closes. I tried a nohup and & to see if that would help but it does not. I'm wondering why I can no longer see anything on my tty.

This is what my putty session looks like. So I have a fully functional session but I can't see any output.
[user@test1 ~]$ ssh cxxx
user@test1's password:
Last login: Thu Sep 12 09:56:01 2013 from 10.x.x.x

if [ -z $PS1 ]
    echo "" > /dev/null
    DATE="/bin/date"  SCRIPT="/usr/bin/script"
       if [ -d "${LOGBASE}" ]; then
           TIMESTAMP="$( ${DATE} +%Y%m%d%H%M%S )"
           umask 077
           [[ "${SHELL}" = "/bin/bash" && -e "${HOME}/.bash_profile" ]] && . ${HOME}/.bash_profile
           ${SCRIPT} -f -q ${LOGFILE}.log | /bin/logger
           [[ "${SHELL}" = "/bin/bash" && -e "${HOME}/.bash_logout" ]] && . ${HOME}/.bash_logout

 PostPosted: Wed Sep 18, 2013 2:33 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 684
Location: Des Moines, Iowa
Instead of piping it directly to the logger, look at using the "tee" command, that way you can see it on your screen and send it to the logger as well.

 Profile WWW  
 PostPosted: Wed Sep 18, 2013 5:12 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 613
hi crouse,

unfortunately that doesn't work either.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group