- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: su to different users, and run a command...
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
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
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
тАО12-04-2003 08:01 AM
тАО12-04-2003 08:01 AM
su to different users, and run a command...
for ID in `cat users`
do
su - $ID<<-EOF
netstat -rn
EOF
done
The issue with this cripts is when I run it, and su to the next user, it always stop at the line of "TERM = (hp)", and I have to hit "RETURN" to let it continue.
I don't know where is this line coming from, and how to let the script continue without hitting "RETURN".
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2003 08:04 AM
тАО12-04-2003 08:04 AM
Re: su to different users, and run a command...
make sure TERM is set in the script.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2003 08:07 AM
тАО12-04-2003 08:07 AM
Re: su to different users, and run a command...
The term entry comes from the profile of the user. To remove that from happening, change the profile to disable evaulating TERM variable. Do this under the section "setup the terminal" in the .profile.
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2003 08:08 AM
тАО12-04-2003 08:08 AM
Re: su to different users, and run a command...
You did not understand my question.
For a reason, I can't use su - user -c "commandline", I have to do the way I showed you in last message.
Why I need to setup TERM, and where I should do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2003 08:09 AM
тАО12-04-2003 08:09 AM
Re: su to different users, and run a command...
if tty -s
then
eval $(ttytype -s)
tabs
...etc...
fi
This avoids error messages like "not a typewriter" and hangs waiting to automatically identify a terminal using tset or ttytype.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2003 08:13 AM
тАО12-04-2003 08:13 AM
Re: su to different users, and run a command...
There are a lot of users involvied, so by changing every one of .profile is not practical. Besides, I doubt that is the cause. Since there is no such line "TERM = (hp)" in several user's .profile. I've just checked out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2003 08:19 AM
тАО12-04-2003 08:19 AM
Re: su to different users, and run a command...
Yours sounds the solution, although I don't quite udnerstand it.
Where I should put your codes, in my scripts?
Where in my scripts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2003 08:23 AM
тАО12-04-2003 08:23 AM
Re: su to different users, and run a command...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2003 08:24 AM
тАО12-04-2003 08:24 AM
Re: su to different users, and run a command...
for ID in `cat users`
do
su - $ID<<-EOF
netstat -rn
EOF
done
can it be changed to:
for ID in `cat users`
do
su $ID<<-EOF
netstat -rn
EOF
done
That will negate the need to load the user profile and the TERM variable. Bill's code in the .profile would allow your code to work unmodified.
SEO
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-05-2003 01:05 AM
тАО12-05-2003 01:05 AM
Re: su to different users, and run a command...
A couple of notes about profiles: the Bourne (/usr/old/bin/sh) and POSIX shells (HP-UX sh and ksh) will run /etc/profile first followed by $HOME/.profile, assuming you are using the default files (copies are kept in /usr/newconfig). So global changes are best kept in /etc/profile. This true for normal telnet logins as well as su - logins.
Now since users can change their .profile, I like to use a standard .profile and keep it in /etc/skel. This location is where SAM and useradd get the default files for a new user's $HOME directory. Now, when a user decides to experiment with .profile, I simply move their broken .profile and put the default one (/etc/skel/.profile) back (or have them do it).
Now for workstations (ie, Xwindows and VUE/CDE, etc), it gets complicated. The default action for xterm,hpterm and dtterm is to bypass all profiles (don't ask why) so these initialization files are skipped. Now you can edit .dtprofile and change DTSOURCEPROFILE=true but this still skips /etc/profile completely. The best fix is to restore the 'normal' login procedure to the Xwindow terminals by specifying -ls when starting xterm, hpterm or dtterm, or (even easier), do this in the $HOME directory of the machine that is running Xwindows and supplying the terminal programs:
echo 'loginShell:true' >> $HOME/.Xdefaults
There are other features you can put into .Xdefaults--see the man pages for the terminal emulators.
Bill Hassell, sysadmin