- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script/cron question
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
12-03-2002 02:36 PM
12-03-2002 02:36 PM
script/cron question
I have a script run by an id then switch to another id in the middle of the script to complete the process.
i.e :
#/bin/ksh
...
....
(sleep 2
echo 'checkuser.sh'
sleep 2
exit ) | sw audituser
...
...
Note : sw - command to switch userid
The script run well if I ran it from command prompt but not thru cronjob. I am getting the follwoing error message:
rocess not attached to terminal
Usage: who [-rbtpludAasHTqRm] [am i] [utmp_like_file]
r run level
b boot time
t time changes
p processes other than getty or users
l login processes
u useful information
d dead processes
A accounting information
a all (rbtpludA options)
s short form of who (no time since last output or pid)
H print header
T status of tty (+ writable, - not writable, x exclusive open, ? hung)
q quick who
R print host name
Switching to audituser
pwd^M
Closed connection.^M
Process Completed
The requirement is to run the script under user A and then switch to user B (you cannot directly logged as user B but have to swtich from another user)
Is there any workaround?
Is there a different way to approach the problem?
I believe the SW script use whoami command and that is why it failed it is executed from cron and I can only use sw to switch id.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2002 02:52 PM
12-03-2002 02:52 PM
Re: script/cron question
su without any option will complain if it does not have any terminal associated with it. I would suggest you run it using this way
su - audituser -c /wherever/checkuser.sh
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2002 05:18 PM
12-03-2002 05:18 PM
Re: script/cron question
The "su - audituser -c <script>" prompt for password.
audituser is a "no login id", it doesn't have password. The only way to logon to this account is from another user than switch to this user(in my case use sw command).
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2002 05:50 PM
12-03-2002 05:50 PM
Re: script/cron question
fix the script?
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2002 06:06 PM
12-03-2002 06:06 PM
Re: script/cron question
If you are any other user, you will be prompted for a passwd if / when you 'su - username' to another user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2002 12:55 AM
12-04-2002 12:55 AM
Re: script/cron question
To better help you, you should perhaps give us the 'sw' script, but the idea would be to add tests like :
if [ -t 1 ]
then
# stdout is a terminal
use whoami and stuff like stty
else
# run with no attached terminal (ie cron)
use another way to find info if really needed
fi
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2002 12:58 AM
12-04-2002 12:58 AM
Re: script/cron question
You can use Expect scripting to automate such a process. The autoexpect tool makes this a breeze by creating the script for you as you walk through the su process.
The downside is that the Expect script will contain your user's password within itself.
If you have issues with the "whoami" command, then use the "who am i" command instead. One reports the user you su'ed to, the other reports the user you su'ed from.
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2002 09:32 AM
12-04-2002 09:32 AM
Re: script/cron question
I know the problem is with the
'sw script' and need to have the logic suggested by Jean.
Thanks everyone.