11-17-2006
Sign on/Sign off logging script
I'd like to make a script that I can execute every time I sign on to my linux box that keeps track of the time and allows to me to add a remark to a file. So basically once I log in, I run the script, and it outputs the date and time to a text file (log.txt). But that isn't my problem.
I need to know how to make it so once i've executed the script in a session, it won't allow me to execute it twice until i've run a sign out script. I'd like it to say something along the lines of "Sorry, you are already signed in!" if i've already run the sign in script.
Then, I need to know what to add to the sign OUT script in order to make it go back to normal the normal signed out state.
I don't know if this makes any sense, but any input would be appreciated! I'll be checking the thread to answer any questions as often as possible. Thanks.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Does % sign have any impact, special meaning in unix shell scripts ??? (2 Replies)
Discussion started by: sokash
2 Replies
2. UNIX for Dummies Questions & Answers
I have created the following script to add 2 numbers together :
lazyadd2 script :
#!/bin/bash
#I have added the she-bang script above as I felt that this would be a good idea.
#The script takes in 2 arguments that are added together
num3=`expr $num1 + $num2`
echo $num3
I make the... (9 Replies)
Discussion started by: Birdi6022
9 Replies
3. UNIX for Dummies Questions & Answers
why a minus sign is put for options in unix commands
suggestions plz (2 Replies)
Discussion started by: trichyselva
2 Replies
4. UNIX for Dummies Questions & Answers
I am using Mac OS X version 10.5.7, and had a problem accessing a folder on our shared area network. I logged in via terminal (bash shell), and did a ls -l on the main directory, and the directory that isn't showing up has an @ sign at the end:
rwxr-xr-x@ 19 admin staff 2048 Jun 1 07:53... (1 Reply)
Discussion started by: aaronstella
1 Replies
5. Shell Programming and Scripting
Hi
I have a file inw which values are seperated by "|"
I want to count number of values present in each line of the file
Input file
AS|23 34|BD|A2|890
AK|23 44|D|A2|89076|89
AF|23 34|BD|A2|8
Result
5
6
5
there are 5 values inside | sign hence o/p will be 5 similarly in... (2 Replies)
Discussion started by: aaysa123
2 Replies
6. Shell Programming and Scripting
hi so I was debugging some scripts and I ran into a problem that did not come up before
grep -n "$variable"$ ./file.txt
I figured the second $ is meant to reference the end of the line but this gave me trouble in my c shell. anyone know whats wrong here or how to rewrite this???
Thank... (2 Replies)
Discussion started by: vas28r13
2 Replies
7. Shell Programming and Scripting
I am having an issue where I am do an SSH to about 30 servers one at a time however my script is getting hung up sometimes on the SSH.
I thought the & at the end as seen below would fire it and move on but that does not seem to be working.
#!/bin/s
for remsys in trumpetsnail angel delphin... (3 Replies)
Discussion started by: LRoberts
3 Replies
8. Shell Programming and Scripting
Suppose you have a line like this:
cn=user.blr.ou=blr.india.o=company
The line should be converted like this:
cn=user.blr,ou=blr.india,o=comapny
Was wondering how to do that using shell script.
Please use tags where appropriate, thank you (4 Replies)
Discussion started by: saurabhkoar
4 Replies
9. Forum Support Area for Unregistered Users & Account Problems
I am unable to sign in to the UNIX forum. I tried my username "timotei2" and the password - but access was denied. My email address - <removed> - was not recognised, either. This is strange as I registered some years back. Should I re-register, or can nyou re-set my log in credentials? (1 Reply)
Discussion started by: Unregistered
1 Replies
10. Forum Support Area for Unregistered Users & Account Problems
I tried logging in under my username (Michael Mullig) but as it's been a while I've forgotten my password. None of my email addresses are recognized either. Thinking that my username my have been purged due to lack of activity (understandable) I tried to re-register, only to find the name is still... (2 Replies)
Discussion started by: Mike Mullig
2 Replies
LEARN ABOUT XFREE86
script
SCRIPT(1) User Commands SCRIPT(1)
NAME
script - make typescript of terminal session
SYNOPSIS
script [options] [file]
DESCRIPTION
script makes a typescript of everything displayed on your terminal. It is useful for students who need a hardcopy record of an interactive
session as proof of an assignment, as the typescript file can be printed out later with lpr(1).
If the argument file is given, script saves the dialogue in this file. If no filename is given, the dialogue is saved in the file type-
script.
OPTIONS
-a, --append
Append the output to file or to typescript, retaining the prior contents.
-c, --command command
Run the command rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves
differently when its stdout is not a tty.
-e, --return
Return the exit code of the child process. Uses the same format as bash termination on signal termination exit code is 128+n.
-f, --flush
Flush output after each write. This is nice for telecooperation: one person does `mkfifo foo; script -f foo', and another can
supervise real-time what is being done using `cat foo'.
--force
Allow the default output destination, i.e. the typescript file, to be a hard or symbolic link. The command will follow a symbolic
link.
-q, --quiet
Be quiet (do not write start and done messages to standard output).
-t[file], --timing[=file]
Output timing data to standard error, or to file when given. This data contains two fields, separated by a space. The first field
indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time.
This information can be used to replay typescripts with realistic typing and output delays.
-V, --version
Display version information and exit.
-h, --help
Display help text and exit.
NOTES
The script ends when the forked shell exits (a control-D for the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not
set) for the C-shell, csh(1)).
Certain interactive commands, such as vi(1), create garbage in the typescript file. script works best with commands that do not manipulate
the screen, the results are meant to emulate a hardcopy terminal.
It is not recommended to run script in non-interactive shells. The inner shell of script is always interactive, and this could lead to
unexpected results. If you use script in the shell initialization file, you have to avoid entering an infinite loop. You can use for
example the .profile file, which is read by login shells only:
if test -t 0 ; then
script
exit
fi
You should also avoid use of script in command pipes, as script can read more input than you would expect.
ENVIRONMENT
The following environment variable is utilized by script:
SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed.
(Most shells set this variable automatically).
SEE ALSO
csh(1) (for the history mechanism), scriptreplay(1)
HISTORY
The script command appeared in 3.0BSD.
BUGS
script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects.
script is primarily designed for interactive terminal sessions. When stdin is not a terminal (for example: echo foo | script), then the
session can hang, because the interactive shell within the script session misses EOF and script has no clue when to close the session. See
the NOTES section for more information.
AVAILABILITY
The script command is part of the util-linux package and is available from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils
/util-linux/>.
util-linux June 2014 SCRIPT(1)