1836568 Members
1907 Online
110102 Solutions
New Discussion

Re: Shell programming

 
SOLVED
Go to solution
Kerry_1
Contributor

Shell programming

Hi everybody
I have written the script on hp-ux 10.20, which includes "tar cvf" command. This script is started by cron using the string which redirects stdout to "> /dev/pts/0"-everything to X-terminal of CDE. Everything is OK but tar command doesn't stdout anything.So how can I stdout the protocol of tar command to /dev/pts/0 ?
Thank you.
4 REPLIES 4
Sanjay_6
Honored Contributor

Re: Shell programming

Hi Kerry,

/dev/pts/0 is assigned dynamically to the terminal which connects to the system. so when you try to redirect the output of the tar command to /dev/pts/0 there should be someone connected to the system using the port /dev/pts/0.

Normally we redirect output of the commands to a file, that makes it easy to keep track of any errors.

Hope this helps.

regds
Deepak Extross
Honored Contributor

Re: Shell programming

Kerry,
Remember that tar spews it "output" onto stderr, not stdout.
You may want to try redirecting the standard error (2) instead of standard output (1)

Hope this helps.
Peter Kloetgen
Esteemed Contributor
Solution

Re: Shell programming

Hi Kerry,

The standard out of tar is channel 2 (normally standard error), so try the following:

script_name >/dev/pts/0 2&>1

using this way, you first redirect the output of all other commands to standard output, and the output of the tar- command is also redirected to the same terminal.


Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Steven Sim Kok Leong
Honored Contributor

Re: Shell programming

Hi Peter,

No offence but I think there is a small typo in your response. It should be:

script_name >/dev/pts/0 2>&1

Hope this helps. Regards.

Steven Sim Kok Leong