- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Terminal or not Terminal
Operating System - HP-UX
1752780
Members
6345
Online
108789
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
Discussions
Discussions
Forums
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
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
тАО12-18-2003 02:40 AM
тАО12-18-2003 02:40 AM
Re: Terminal or not Terminal
The -t test does more than simply look to see if the file descriptor is open, it tests to see whether or not, it is assiciated with a tty (terminal) device. It can be used, for example, to test whether a process is interactive or if stdin is coming from a pipe.
Try this trivial test:
Create my.sh,
if [[ -t 0 ]]
then
echo "Terminal"
else
echo "Not Terminal"
fi
Now invoke it thusly:
my.sh
and then
echo "Dummy" | my.sh
Man test for details. You could also use the more familiar "if [ -t 0 ]" syntax but the double brackets are more efficient because it uses the POSIX (or Korn) shell's internal test rather than forking the external test command.
Try this trivial test:
Create my.sh,
if [[ -t 0 ]]
then
echo "Terminal"
else
echo "Not Terminal"
fi
Now invoke it thusly:
my.sh
and then
echo "Dummy" | my.sh
Man test for details. You could also use the more familiar "if [ -t 0 ]" syntax but the double brackets are more efficient because it uses the POSIX (or Korn) shell's internal test rather than forking the external test command.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 02:58 AM
тАО12-18-2003 02:58 AM
Re: Terminal or not Terminal
Ah! I see.
So when I pipe to something, the something is not part on the part of the current process it is a subprocess that is not part of the terminal process. Well kinda.
Thanks for the man test. Didn't know tat was there.
Marty
So when I pipe to something, the something is not part on the part of the current process it is a subprocess that is not part of the terminal process. Well kinda.
Thanks for the man test. Didn't know tat was there.
Marty
The only thing that always remain the same are the changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 07:46 AM
тАО12-18-2003 07:46 AM
Re: Terminal or not Terminal
Hi Marty,
stdin,stdout,stderr are not allways associated with a device. Not only when you pipe, also when you redirect <> or run a process in the backgound, lets say as a crontab or at job.
have fun,
Michael
stdin,stdout,stderr are not allways associated with a device. Not only when you pipe, also when you redirect <> or run a process in the backgound, lets say as a crontab or at job.
have fun,
Michael
- « Previous
-
- 1
- 2
- Next »
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP