Results 1 to 2 of 2
Hi Everyone, I have written a C Shell wrapper script for "cat" command in the linux such that whenever any uses the "cat" command and it logs to some file, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 01-31-2012 #1
- Join Date
- Feb 2011
C Shell Wrapper script for cat command in linux
I have written a C Shell wrapper script for "cat" command in the linux such that whenever any uses the "cat" command and it logs to some file, so the script is as
set command = /etc/temp/cat
set logfile = /etc/cat_command.log
echo "$LOGNAME + $command $argv " >> $logile
So , i have move the original "cat" command from "/bin" and replaced it with this script so whenever any one uses it logs
But my problem is whenver any user uses as
1) cat sample.txt or cat 1.txt 2.txt , it will log properly
2) cat sample.txt > /tmp/temp.txt , for this only command and arguments are logged but redirection and redirection path is not logged so is there any way to log that path also.
Looking forward your reply as it is urgent. Thanks in Advance
- 06-03-2012 #2
- Join Date
- Apr 2009
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
I/O redirection are handled at the top-most level shell, and don't propagate to your script. To do what you want will require some C or C++ coding I think, in that you will need to capture stdin/stdout targets directly. It may be doable in CSH, but I don't know for sure if that is possible... too many years since I last wrote a lot of csh code.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!