- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Interactive or not
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
06-26-2006 03:12 AM
06-26-2006 03:12 AM
Interactive or not
I need to change my DISPLAY settings, so I try to figure out if my script runs interactive or from cron. Therefore I'm trying to run the script example from thread 63219, but it gives errors.
Any help is appreciated!
#!/usr/bin/sh
[ -t 0 ] && print -u2 "stdin is interactive"
[ -t 1 ] && print -u2 "stdout is interactive"
[ -t 0 ] || print -u2 "stdin is NOT interactive"
[ -t 1 ] || print -u2 "stdout is NOT interactive"
exit 0
./my.sh
./my.sh[2]: Syntax error at line 2 : `&' is not expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2006 03:16 AM
06-26-2006 03:16 AM
Re: Interactive or not
Simply test this way:
if [ -t 0 ]; then
echo "I'm running interactively"
else
echo "I am not associated with a tty!"
fi
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2006 03:22 AM
06-26-2006 03:22 AM
Re: Interactive or not
Did you actually copy and paste the script containing "[" and "]", or did you substitute "[" and "]" (left and right brackets) for these character codes?
The script should read:
#!/usr/bin/sh
[ -t 0 ] && print -u2 "stdin is interactive"
[ -t 1 ] && print -u2 "stdout is interactive"
[ -t 0 ] || print -u2 "stdin is NOT interactive"
[ -t 1 ] || print -u2 "stdout is NOT interactive"
exit 0
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2006 03:23 AM
06-26-2006 03:23 AM
Re: Interactive or not
I am not associated with a tty!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2006 03:26 AM
06-26-2006 03:26 AM
Re: Interactive or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2006 03:26 AM
06-26-2006 03:26 AM
Re: Interactive or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2006 03:31 AM
06-26-2006 03:31 AM
Re: Interactive or not
if [ -t 0 ]; then
# script running from command line
else
# script run by cron
fi
exit 0
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2006 03:31 AM
06-26-2006 03:31 AM
Re: Interactive or not
I'm getting it. Thanks for the quick replies!