- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: |& - Pipe
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
Discussions
Discussions
Forums
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
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
тАО07-20-2004 11:13 AM
тАО07-20-2004 11:13 AM
this is from the man page of sh-posix
|& Causes asynchronous execution of the preceding command or
pipeline with a two-way pipe established to the parent
shell. The standard input and output of the spawned command
can be written to and read from by the parent shell using
the -p option of the special commands read and print.
man page doesnt make much sense to me and /sbin/init.d/swconfig seem to use that
# grep "\|\&" /sbin/init.d/swconfig
ls |&
ls |&
cat /var/adm/sw/cleanupfile |&
#
I understand
I was wondering if you guys are aware of any other use to this syntax or when it can be best used ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2004 05:08 PM
тАО07-20-2004 05:08 PM
SolutionWhilst we do this for a number of bits and pieces using the perl 'open()' pipe, it could just as easily use this.
If you look into where those |& pipes are used in /sbin/init.d/swconfig, you'll see shortly after them what use they are put too:
# If exist, cleanup alternate cmds
if [[ -d /usr/lbin/sw/bin ]]
then
(
typeset first=1
cd /usr/lbin/sw/bin
ls |&
while read -p old_cmd
do
if [[ ${first} = 1 ]]
then
msg star "Removing files from '/usr/lbin/sw/bin'"
first=0
fi
rm -f ${old_cmd}
done
)
fi
It goes through a directory listing of the current directory, and removes them, bypassing the need for shell expansion.
The second entry isn't all that more exciting (identical infact), and the third use makes it just a little testing and stuff, before moving the '/var/adm/sw/cleanupfile' out of the way.
If you had a program of which did question/answer however, the |& starts to be of more use. You send it a question with 'print -p
Or you could use the '>&p' and '<&p' to output/input from your own custom commands into the backgrounded pipe.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2004 07:37 PM
тАО07-20-2004 07:37 PM
Re: |& - Pipe
Here's another example that is quite useful.
bc |&
print -p "10 + 10"
read -p answer
echo $answer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2004 08:58 PM
тАО07-20-2004 08:58 PM
Re: |& - Pipe
example to use a socket in a script:
telnet anothersystem 7 |&
exec 3<&p 4>&p
cat <&3 &
echo hello >&4
exec 4>&-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2004 12:47 AM
тАО07-21-2004 12:47 AM
Re: |& - Pipe
0 0 * * * [ -d /oracle/PROD/920_64 ] && /export/APPL/spaceman/cleanarch > /dev/null 2>&1
That checks to see if the directory /oracle/PROD/920_64 exists, and if yes, then executes the cleanarch script...
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2004 10:32 AM
тАО07-21-2004 10:32 AM
Re: |& - Pipe
Sorry Geoff, I think you have misread the question. I was talking about "|&" and not about "&&".