HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script command usage
Operating System - HP-UX
1831219
Members
2978
Online
110021
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
11-21-2003 07:31 AM
11-21-2003 07:31 AM
Is there any way to force the script command to capture information to a file when a user executes a script??
We have cases were they are running a normal application script, and either not catching an error or something, but later on saying things didn't work right but have no information from the origional run.
Would like to force the script command to execute without them realizing it or having to do anything so I can check later on when they complain...
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2003 07:35 AM
11-21-2003 07:35 AM
Re: script command usage
You can actually redirect the standard output to a file:
# script_name > output_file_name
OR
# script_name > output_file_name 2>&1
If are talking about the 'script' command, you can capture the output like this:
# script file_name
Now, after this, whatever they type and the result will be stored on this file.
# script_name > output_file_name
OR
# script_name > output_file_name 2>&1
If are talking about the 'script' command, you can capture the output like this:
# script file_name
Now, after this, whatever they type and the result will be stored on this file.
Life is a promise, fulfill it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2003 07:38 AM
11-21-2003 07:38 AM
Re: script command usage
Hi,
(
Script commands
) 1>/tmp/logfile 2>&1
Thanks,
Sundar
(
Script commands
) 1>/tmp/logfile 2>&1
Thanks,
Sundar
Learn What to do ,How to do and more importantly When to do ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2003 08:11 AM
11-21-2003 08:11 AM
Solution
The easiest way is to trace the script every time they run it. To do that, use exec at the beginning to change stderr to a secret file and then start the script, something like this:
#!/usr/bin/sh
#
# log stderr here
# Use pid and username in filename
MYNAME=${0##*/}
MYUSER=$(/usr/bin/id -run)
exec 2> /var/tmp/$MYNAME-$MYUSER-$$.log
set -x
...rest of script...
Now the script works as before except every step is recorded in the file: scriptname-username-PID.log. Note that as with all scripts, set -x affects the current script and has no effect on functions nor will it report on what an external command might return.
Bill Hassell, sysadmin
#!/usr/bin/sh
#
# log stderr here
# Use pid and username in filename
MYNAME=${0##*/}
MYUSER=$(/usr/bin/id -run)
exec 2> /var/tmp/$MYNAME-$MYUSER-$$.log
set -x
...rest of script...
Now the script works as before except every step is recorded in the file: scriptname-username-PID.log. Note that as with all scripts, set -x affects the current script and has no effect on functions nor will it report on what an external command might return.
Bill Hassell, sysadmin
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP