- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Trying to have a script log user off machine as la...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 09:41 AM
07-27-2001 09:41 AM
What is the command to log off the machine or how can I do that in my script?
thanks,
Boyd
PS - I already know how to script a shutdown or reboot.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 09:50 AM
07-27-2001 09:50 AM
Re: Trying to have a script log user off machine as last step.
exit
at the end of the script
later
Ajay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 10:00 AM
07-27-2001 10:00 AM
Re: Trying to have a script log user off machine as last step.
You may define the user in the /etc/passwd like the following :
user1:*:uid:gid:Comment:homeDir:PathScript
PathScript: should be a script which direct the user to do what he is intended to do and one that user finish with that script "PathScript" the session terminates.
PathScript could be like : "/home/user1/StartAndFinish.sh".
Magdi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 10:01 AM
07-27-2001 10:01 AM
SolutionI have two window when I run command who
#who
sachin ttyp1 Jul 27 09:48
sachin ttyp2 Jul 27 12:57
#tty
/dev/ttyp2
am in ttyp2
Now I can run ps -ef |grep ttyp2 from ttyp1 and kill -9 pids
On ttyp1
#ps -ef |grep ttyp2
sachin 2814 2813 0 12:57:36 ttyp2 0:00 csh
#kill -9 2814 2813
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 10:12 AM
07-27-2001 10:12 AM
Re: Trying to have a script log user off machine as last step.
Assuming that your user has logged in and runs the script in his login shell, then in the script as the last statement, do:
# exec /usr/bin/false
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 10:31 AM
07-27-2001 10:31 AM
Re: Trying to have a script log user off machine as last step.
The easiest way to get an exit is to start the script with the dot command. The dot command is a single . followed by white space and then the script's name. If the script is called mybackup, then you would run the script with:
. /pathname/mybackup
See the dot? The current shell will execute each command and when exit is seen, it will exit which logs out.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 10:34 AM
07-27-2001 10:34 AM
Re: Trying to have a script log user off machine as last step.
It just exits the script.
Boyd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 10:38 AM
07-27-2001 10:38 AM
Re: Trying to have a script log user off machine as last step.
My previous answer works for me. I have test it on my system. you just have to implement in your script.
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 10:47 AM
07-27-2001 10:47 AM
Re: Trying to have a script log user off machine as last step.
work.
I'm wondering if I may not be clearly stating what I
am trying to do. As the last step of a script, I want
the machine to be logged off just like it would
if I clicked on the EXIT icon on the CDE menu
at the bottom of my screen or if I clicked on my
Log Off menu option from the right click mouse
button menu.
This way, I can run my script that do a bunch of
stuff and leave for the day with the idea that the script
will log me off the machine as its last step. Thus,
the screen lock will not prohibit someone else that
may need to log on the machine, especially if I left
for the day.
thanks,
Boyd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 11:08 AM
07-27-2001 11:08 AM
Re: Trying to have a script log user off machine as last step.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 11:35 AM
07-27-2001 11:35 AM
Re: Trying to have a script log user off machine as last step.
As for the user, Bill Hassel gave the best answer, but you have to think about how your script is bein accesses. If people are sitting at a terminal, and opening a dtterm from CDE, It will Not work! If they are using telnet to access the machine, then it will. It would also work if you put your script as the log-in shell for the user. Remember that these it is easy to get around this type of, for lack of better terms, security.
If I telnet to your box, and am given a shell, I can type "^Z", "^C", "^Q", or if I am given a prompt at any time, could issue a few shells of my own from the prompt to circumvent what your trying to do.
If all they need is an shell with some prompts you give them, then you can trap any interupt sent by the user.
Regards,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 11:49 AM
07-27-2001 11:49 AM
Re: Trying to have a script log user off machine as last step.
I agree. But the question wasn't clear.
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 12:06 PM
07-27-2001 12:06 PM
Re: Trying to have a script log user off machine as last step.
Another solution is to change CDE to execute your script on logoff.
Upon logoff, CDE executes whatever the resource Dtlogin*reset: points to, which is set to 'Xreset' by default (I'm looking at the various stuff in /usr/dt/config here). You can redefine this to call your script, which should call the real Xreset when it's done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 12:29 PM
07-27-2001 12:29 PM
Re: Trying to have a script log user off machine as last step.
Do This:
nohup /my/script/to/run.sh &
Then just exit. The script will continue to run even after you log off.
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2001 05:02 AM
07-30-2001 05:02 AM
Re: Trying to have a script log user off machine as last step.
If I understand it correctly you want to start non-interactive scripts and go home, then have the terminal logged out!?
One way of doing this is to use the "batch" command.
Put your scripts in a file, then:
$ batch < job-file
job 996497765.b at Mon Jul 30 14:56:05 2001
$ logout
This way the terminal will be available directly, job secured and detached from terminal.
Output from the job will be mailed to you.
(see "man batch")
Good Luck!
/Rolf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2001 09:54 AM
07-30-2001 09:54 AM
Re: Trying to have a script log user off machine as last step.
I ended up with the following two possibilitities.
who -u | grep console | kill -9 `awk '{ print $7 }'`
or
ps -ef | grep dtsession | grep -v grep | kill -9 `awk '{ print $3 }'`
The first one is dependent on the idea that the 7th field will always be the PID.
The second one came from Chris' idea of terminating the window manager process (dtwm). But, I found that I need to terminate the parent process of the dtsession process which is the parent process of the dtwm process.
The PID of the first approach is the same PID of the second approach.
thanks,
Boyd