- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Determining Where Script Was Started From
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
03-05-2004 05:54 AM
03-05-2004 05:54 AM
Re: Determining Where Script Was Started From
a login shell has a leading dash
in your profile
case $0 in
-*) loginshell=true;;
*) loginshell=false;;
esac
and if interactive
case $- in
*i*) interactiveshell=true;;
*) interactiveshell=false;;
esac
and if attached to a terminal
if [[ -t 0 ]] ;then
terminal=true
else
terminal=false
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 06:05 AM
03-05-2004 06:05 AM
Re: Determining Where Script Was Started From
the standard installation of CDE doesn't source /etc/profile. So, the only way you'd be in /etc/profile is if one of your scripts was sourceing it, i.e. $0 would not be -sh.
The above is true unless you've customized the CDE login to source /etc/profile somewhere. And, it shouldn't be too hard to set something up to recognize your sourceing /etc/profile during the CDE startup.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 06:06 AM
03-05-2004 06:06 AM
Re: Determining Where Script Was Started From
what is the desired behavior when logging into CDE ?
Get /etc/copyright for each hpterm that is opened or only for the very first one ?
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 06:14 AM
03-05-2004 06:14 AM
Re: Determining Where Script Was Started From
You're on the right track - we force /etc/profile to be sourced in .dtprofile. I could recognize this and cat /etc/copyright only then, but that leads to Volker's question:
Volker,
My preferred behaviour would be to have the copyright display for each hpterm opened.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 06:21 AM
03-05-2004 06:21 AM
Re: Determining Where Script Was Started From
How about this:
PP1=$(ps -fp $PPID | grep -v PID | awk '{print $3}')
PP2=$(ps -p $PP1 | grep -v PID | awk '{print $4}')
if [ "${PP2}" = "hpterm" ] ; then
cat /etc/copyright
fi
PP1 will get the PPID of the current process, which should be the shell, and then PP2 gets the PPID of the shell, which should be hpterm. Soo if PP2 = hpterm then show /etc/copyright. You could do the same thing for dtterm as well. I think this should work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 06:23 AM
03-05-2004 06:23 AM
Re: Determining Where Script Was Started From
echo "\nThe copyright notice on this machine ($(hostname)) can read"
echo "by typing: cat /etc/copyright"
so I don't have to look at it anymore then I want to. Of course, when using CDE you get a big screen full of it (unless you customize that also). So, you don't have to show it again for every terminal window started.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 06:32 AM
03-05-2004 06:32 AM
Re: Determining Where Script Was Started From
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 06:50 AM
03-05-2004 06:50 AM
Re: Determining Where Script Was Started From
you can put something like
*loginShell: true
in the ~/.Xdefaults file or approriate cde configuration file. This will make each hpterm/dtterm/xterm's shell a login shell. But, /etc/profile still isn't sourced just the $HOME/.profile is.
So, if you wanted each hpterm to print a copyright. I think you could do by setting the above resource, then in $HOME/.profile have the copyright printed if the shell is interactive.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 06:54 AM
03-05-2004 06:54 AM
Re: Determining Where Script Was Started From
Any script, batch or cron, invokes another script, we'll call it envscript, that was supposed to set all the required environment variables (this just in case it was cron - overkill otherwise). We also had some menuing applications that had there own variable setups. And, of course, we had /etc/profile that was handling the CDE logins (because we forced it to be read via .dtprofile).
I wanted to consolidate all this and just have one source for environment variables: /etc/profile.
The answer in this case was to add a variable in envscript and then test it in /etc/profile. I aplogize for torturing everyone when the solution was so simple. I just couldn't see it (as you could tell from my first attempt to state the problem). I was trying to make it more complicated than it needed to be.
Thanks all,
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2004 07:32 AM
03-05-2004 07:32 AM
Re: Determining Where Script Was Started From
But this long thread just got me off. Time to leave.
Anil
- « Previous
-
- 1
- 2
- Next »