HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scripting
Operating System - HP-UX
1833877
Members
1584
Online
110063
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
08-11-2003 03:55 PM
08-11-2003 03:55 PM
Hi,
Can anyone explain the following code?
jobs -l | while IFS="${IFS}[]()" read w job w pid w rc w
do
((rc)) && { #particularly this line
print -u2 "Job failed"
print -u2 "PID=$pid RC=$rc"
}
done
Thanks.
Can anyone explain the following code?
jobs -l | while IFS="${IFS}[]()" read w job w pid w rc w
do
((rc)) && { #particularly this line
print -u2 "Job failed"
print -u2 "PID=$pid RC=$rc"
}
done
Thanks.
Never quit
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2003 04:35 PM
08-11-2003 04:35 PM
Re: Scripting
Hi,
The code is getting a list of background jobs and assigning the output to variables.
If the result of ((rc)) is true/successful, then it prints the message "Job failed" to stderr.
Refer to the sh-posix(1) man page and the Shell Users Guide for more information.
Tim.
The code is getting a list of background jobs and assigning the output to variables.
If the result of ((rc)) is true/successful, then it prints the message "Job failed" to stderr.
Refer to the sh-posix(1) man page and the Shell Users Guide for more information.
Tim.
Yesterday is history, tomorrow is a mystery, today is a gift. That's why it's called the present.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2003 07:05 PM
08-11-2003 07:05 PM
Solution
jobs -l displays process id's after the job number, in addition to the usual information. it displays the job number in [], with a + in front of curent job number, and - in front of previous job number, the status (running, stopped, done, terminated, etc), a number in () after Done is the return value of the job. If there is no () after Done, the return value is true. and lastly the command line. the command line is obtained from the history file. if the history file can not be accessed then it does not display the command line and displays instead.
jobs -l
+[4] 139 running cc -c hello.c
-[3] 465 stopped mail jack
[2] 888 Done(1) rm junk
etc
| #pipeline command
the standard output of each command execpt the last one, is connected to the standard input of the next command. return value is the return value of the last specified command
the output of jobs is piped into a while do done loop.
ifs #internal field seperator
one of the many things the ifs is used for is to split into fields the characters the the shell reads with read.
the script is adding [] and () as field seperators for the following read.
uses the read to read a line and split it into fields, using the character in the IFS variable as delimiters. each variable name must be a vaild name. the first field is assigned to the first named var, the second to the second named var, etc.
((word)) #arithmetic command
the shell does command substitution, parameter expansion, arithmethic expansion, and quote removal for each word to generate an arithmetic expression that is evaluated. the return value is true if the arithmetic expression evaluates to nonzero; otherwise false
conditional commands
test-expression && test-expression
evaluates to true if both test-expressions are true. the second test-expression is expanded and evaluated only if the first expression is true
{ compound-list }
this is a brace grouping. the shell runs the compound-list in the current environment
the two print commands are group together so there are both evaluated if ((rc)) is true.
print -u2
prints the message to standard error instead of standard output
jobs -l
+[4] 139 running cc -c hello.c
-[3] 465 stopped mail jack
[2] 888 Done(1) rm junk
etc
| #pipeline command
the standard output of each command execpt the last one, is connected to the standard input of the next command. return value is the return value of the last specified command
the output of jobs is piped into a while do done loop.
ifs #internal field seperator
one of the many things the ifs is used for is to split into fields the characters the the shell reads with read.
the script is adding [] and () as field seperators for the following read.
uses the read to read a line and split it into fields, using the character in the IFS variable as delimiters. each variable name must be a vaild name. the first field is assigned to the first named var, the second to the second named var, etc.
((word)) #arithmetic command
the shell does command substitution, parameter expansion, arithmethic expansion, and quote removal for each word to generate an arithmetic expression that is evaluated. the return value is true if the arithmetic expression evaluates to nonzero; otherwise false
conditional commands
test-expression && test-expression
evaluates to true if both test-expressions are true. the second test-expression is expanded and evaluated only if the first expression is true
{ compound-list }
this is a brace grouping. the shell runs the compound-list in the current environment
the two print commands are group together so there are both evaluated if ((rc)) is true.
print -u2
prints the message to standard error instead of standard output
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