Deepak K M
Deepak K M

Reputation: 561

What does &p refer to?

I am not able to figure out what does &p do in the below script. and does print -u4 mean that whatever argument passed is written in file decriptor 4?

1:  $SRVRMGRCMD |&
3:  BGPID=$!
4:  exec 4>&p
5:  exec 5<&p
6:  sleep 2
7:  # Build a list of Servers
8:  print -u4 "list servers show SBLSRVR_NAME"

Thanks in advance.

Upvotes: 1

Views: 413

Answers (2)

mikeb
mikeb

Reputation: 11267

What language is that?

If it's bash or a shell, it creates a file descriptor to store the output, see here:

http://www.softpanorama.org/Tools/exec.shtml, specifically this part:

exec 3< inputfile   # Opens inputfile with file descriptor 3 for reading.
exec 4> outputfile  # Opens outputfile with file descriptor 4 for writing.
exec 5<&0   # Makes fd 5 a copy of fd 0 (standard input).
exec 6>&p   # Attach fd 6 to co-process.

Edited to say:

The -un says to write all output to the file descriptor n

See here http://alasir.com/books/bsd/428-430.html

Upvotes: 1

wmhiggins
wmhiggins

Reputation: 621

These appear to be references to co-processes (in ksh or zsh).
see https://unix.stackexchange.com/questions/86270/how-do-you-use-the-command-coproc-in-bash

Upvotes: 1

Related Questions