1753814 Members
7539 Online
108805 Solutions
New Discussion юеВ

Shell Redirect error

 
SOLVED
Go to solution
pareshan
Regular Advisor

Shell Redirect error

Hi everyone, While I was trying to do

DATE=`date +"%Y%m%d_%H%M%S"`
STARTLOG=$TUXSTDDIR/start_$DATE.log
tmboot -y > $STARTLOG 2>&1



I got an error i.e. Ambiguous output redirect error. Here the first part is to boot the account so there is nothing wrong with that. I have defined the startlog also but I dint understand why I am having problem here.

I dint get what that error means. I will appreciate any help to make this right.

thanks alot
22 REPLIES 22
James R. Ferguson
Acclaimed Contributor

Re: Shell Redirect error

Hi:

You're using the evil C-shell. Use a real shell (Poxix, Korn, or Bash). Since this is HP-UX, use the Posix shell --- '/usr/bin/sh'.

See this :

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

Regards!

...JRF...
pareshan
Regular Advisor

Re: Shell Redirect error

I think im using korn shell thought I have both ksh and csh. and i did something like that to be exact
#!/bin/ksh

DATE=`date +"%Y%m%d_%H%M%S"`
STARTLOG=$TUXSTDDIR/start_$DATE.log
tmboot -y > $STARTLOG 2>&1

doesnt that mean im using Korn shell?
and if lets suppose that is on csh how can I do something like that in csh? even complex way is fine just want to know how I can do it.

thanks
James R. Ferguson
Acclaimed Contributor

Re: Shell Redirect error

Hi:

Hmmm, so you did specify Korn (#!/bin/ksh).

I could reproduce your "ambiguous output redirect" thusly:

# cat ./myredir.csh
#!/usr/bin/csh
set STARTLOG=/tmp/something
lvlnboot -y > $STARTLOG 2>&1

...but not with:

# cat ./myredir.ksh
#!/usr/bin/ksh
STARTLOG=/tmp/something
lvlnboot -y > $STARTLOG 2>&1

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Shell Redirect error

Hi (again):

Are you running your script remotely, as with an 'remsh' command?

Regards!

...JRF...
pareshan
Regular Advisor

Re: Shell Redirect error

no im not using remsh or running command remotely.
James R. Ferguson
Acclaimed Contributor
Solution

Re: Shell Redirect error

Hi (again):

If you do:

# su - someuser /myscript

...and 's default shell is the C-shell then regardless of the presence of the Korn shell interpreter line in 'myscript' you will produce the error.

Does this match what you are doing?

Regards!

...JRF...
Michael Mike Reaser
Valued Contributor

Re: Shell Redirect error

Please show us how you're invoking the script. First, issue the command

echo $SHELL

and show us the output. Next, issue the command you're using to invoke this script

myscript parm1 parm2 ... parmN

and show us the output from that.
There's no place like 127.0.0.1

HP-Server-Literate since 1979
pareshan
Regular Advisor

Re: Shell Redirect error

No that dint work. Instead of that I guess it will be helpful for me if there is any way to do similar to that in csh so that I can try that one if it works.

tmboot -y > $STARTLOG 2>&1
to me it looks like it should work on korn shell but its not so What im asking is how can we do like that in csh.
pareshan
Regular Advisor

Re: Shell Redirect error

I did the exactly you wanted
> echo $SHELL
/usr/bin/ksh
> set DATE=`date +"%Y%m%d_%H%M%S"`
> set STARTLOG=$TUXSTDDIR/start_$DATE.log
> tmboot -y > $STARTLOG 2>&1
Ambiguous output redirect.
>
here i dont need any parameters and all and I can put this in a file or I can run like this which shouldnt make any difference.