LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-07-2011, 11:30 AM   #1
pandunr
LQ Newbie
 
Registered: May 2011
Posts: 12

Rep: Reputation: Disabled
Writing command executed into logfile


Currently we are using Unix machine & the activity are logged in the file using following code used in profile


.profile code



# /ln/aud_root/dds_ibm/.profile
trap 'print "not allowed"' INT
trap 'print "not allowed"' QUIT
trap 'print "not allowed"' TSTP
PATH="";export PATH
CAIGLBL0000=/unicenter
function error { # log rejections to /var/adm/messages
cause=$1
set $(who -m) # sets id ..... source-addr
echo "SALVO login rejected for $netid by $1 from $6 $cause " # test system only
logger -p daemon.notice "SALVO login rejected for $netid by $1 from $6 $cause"
exit
}

echo "|----------------------------------------------------------------------|"
echo "| 1 rudmrb05 (swidds gerdds gbrdds iredds svkdds swedds) |"
echo "| |"
echo "| 2 rudmrb06 (beldds nordds dendds findds poldds pordds gredds turdds)|"
echo "| (czedds hundds) |"
echo "| |"
echo "| 3 rudmrb07 (autdds espdds fradds holdds itadds) |"
echo "| |"
echo "| 4 rudmra06 (DDS, Osiris Batch Pre-production) |"
echo "| |"
echo "| 5 rudmra07 (SAS, SPS, DEM, Pre-production) |"
echo "| |"
echo "| 9 to change login password |"
echo "| |"
echo "|----------------------------------------------------------------------|"
echo "Choice :-"
umask 0037
read choice
case $choice in
1) server=rudmrb05_app;;
2) server=rudmrb06_app1;;
3) server=rudmrb07_app1;;
4) server=rudmra06;;
5) server=rudmra07;;
9) CAIGLBL0000=/unicenter;
PATH=/usr/bin;
#. /unicenter/scripts/envusr;
$(/usr/bin/passwd);
echo "Password Changed - Please login again"; sleep 2;
exit;;
*) exit;;
esac
echo "enter target user"
read choice2
#LOG=$(/usr/ucb/whoami)_${server}_${choice2}_$(/usr/bin/date +%y%m%d%H%M).log
LOG=$(/usr/bin/date +%y%m%d%H%M)_$(/usr/ucb/whoami)_${server}_${choice2}.log
echo "enter reason for access (ASLog number, ECM Change Number)"
read reason
echo "---------------------------------------------------------------------" >> ${LOG}
echo ${LOG} >> ${LOG}
echo "" >> ${LOG}
echo "Justification - "${reason} >> ${LOG}
echo "---------------------------------------------------------------------" >> ${LOG}
echo "Logging onto server now"
#
/usr/local/bin/ssh -l $choice2 $server | /usr/bin/tee -ai $LOG
exit



We are now migrating Linux and we are going use SUDO to connect application. When we use SUDO to connect application & activities are not logged properly & system also becoming very slow. Here is new code

# SOX implementation: Following code gives user menu to select the DDS instances,
#user’s activity is getting logged
# Written By: Sunil Dagde Date: 04-06-2011

trap 'print "not allowed"' INT
trap 'print "not allowed"' QUIT
trap 'print "not allowed"' TSTP

echo "|----------------------------------------------------------------------|"
echo "| 1 defravmwvmias11 - GERMANY PRE PROD |"
echo "| |"
echo "| 2 defravmwvmias11 - HUNGARY PRE PROD |"
echo "| |"
echo "| 3 to change login password |"
echo "| |"
echo "| 4 Exit From Menu |"
echo "| |"
echo "|----------------------------------------------------------------------|"
echo "Choice :-"
umask 0037
read choice
case $choice in
1) server=defravmwvmias11;;
2) server=defravmwvmias11;;
3) $(/usr/bin/passwd);
echo "Password Changed - Please login again"; sleep 2;
exit;;
4) exit;;
*) exit;;
esac
echo "enter target user"
read choice2
LOG=log/$(date +%y%m%d%H%M)_$(whoami)_${server}_${choice2}.log
echo "enter reason for access (ASLog number, ECM Change Number)"
read reason
echo "---------------------------------------------------------------------" >> ${LOG}
echo ${LOG} >> ${LOG}
echo "" >> ${LOG}
echo "Justification - "${reason} >> ${LOG}
echo "---------------------------------------------------------------------" >> ${LOG}
echo "Logging onto server now"
/usr/bin/sudo su - $choice2 | /usr/bin/tee -ai $LOG


Please suggest

Current
/usr/local/bin/ssh -l $choice2 $server | /usr/bin/tee -ai $LOG
New

/usr/bin/sudo su - $choice2 | /usr/bin/tee -ai $LOG
 
Old 06-08-2011, 01:25 AM   #2
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
When you post code, please use the code tags (either automatically by clicking on the code button in the (advanced) editor or by writing [code and [/code] (with the closing bracket after the key word "code". I can't do it here, it would vanish ). It will make for better readability. Thank you.

Last edited by JZL240I-U; 06-08-2011 at 01:26 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell scripting: Print output to logfile, error to logfile & screen stefanlasiewski Programming 18 05-22-2008 12:47 PM
javascript enabled browser command log file logfile secretlydead Linux - Networking 1 06-26-2007 05:48 PM
how to see which command has been executed ? Volcano Linux - Newbie 4 12-11-2006 08:48 AM
which command executed on which terminal dsids Linux - Newbie 1 09-23-2006 08:57 AM
Writing shell script with mail < logfile humbletech99 Programming 2 11-22-2005 08:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration