- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell Redirect error
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
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
тАО01-07-2009 11:52 AM
тАО01-07-2009 11:52 AM
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
Solved! Go to Solution.
- Tags:
- redirect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 12:08 PM
тАО01-07-2009 12:08 PM
Re: Shell Redirect error
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 12:21 PM
тАО01-07-2009 12:21 PM
Re: Shell Redirect error
#!/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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 12:40 PM
тАО01-07-2009 12:40 PM
Re: Shell Redirect error
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 12:44 PM
тАО01-07-2009 12:44 PM
Re: Shell Redirect error
Are you running your script remotely, as with an 'remsh' command?
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 12:52 PM
тАО01-07-2009 12:52 PM
Re: Shell Redirect error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 01:11 PM
тАО01-07-2009 01:11 PM
SolutionIf you do:
# su - someuser /myscript
...and
Does this match what you are doing?
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 01:19 PM
тАО01-07-2009 01:19 PM
Re: Shell Redirect error
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.
HP-Server-Literate since 1979
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 01:24 PM
тАО01-07-2009 01:24 PM
Re: Shell Redirect error
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 01:34 PM
тАО01-07-2009 01:34 PM
Re: Shell Redirect error
> 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 01:43 PM
тАО01-07-2009 01:43 PM
Re: Shell Redirect error
whence tmboot
which tmboot
file $(whence tmboot)
file $(which tmboot)
ls -l $(whence tmboot)
ls -l $(which tmboot)
and, after youve' done the DATE= and STARTLOG= commands, add
echo $STARTLOG
and post the results.
I presume you've already got "TUXSTDDIR" set and epxorted in your shell environment? Otherwise, you'll be attempting to create a log file direectly under /, which is never a good idea.
HP-Server-Literate since 1979
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 01:56 PM
тАО01-07-2009 01:56 PM
Re: Shell Redirect error
/usr/local/tux81/bin/tmboot
> which tmboot
/usr/local/tux81/bin/tmboot
> whence tmboot
whence: Command not found.
i dint get what you mean by
file $(whence tmboot)
file $(which tmboot)
ls -l $(whence tmboot)
ls -l $(which tmboot)
then i set DATE and STARTLOG as before
then i did
echo $STARTLOG
which gave
/tuxappl/tuxbug/rte_tlg/var/xmk/log/start_090107.log
and yeah I have already set TUXSTDDIR and exported
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 08:10 PM
тАО01-07-2009 08:10 PM
Re: Shell Redirect error
To find your shell: ps -fp $$
>lets suppose that is on csh how can I do something like that in csh?
You don't even want to think about the scummy C shell. Find out why you aren't in a real shell.
>I didn't get what you mean by: file $(whence tmboot)
Type that exact command. But since you are in the scummy C shell, it will fail.
Note: The #! line must be the first line.
>What I'm asking is how can we do like that in scummy C shell:
scummy csh(1) says: command >& file
>Mike: issue the command: echo $SHELL
This isn't good enough, it only gives you your login shell.
One way of checking your shell is to give an invalid command:
abcdef
ksh: abcdef: not found
sh: abcdef: not found.
abcdef: Command not found. # scummy C shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2009 08:40 PM
тАО01-07-2009 08:40 PM
Re: Shell Redirect error
chsh pareshan /usr/bin/sh
Now logout and log back in again. Your active shell will be a sane POSIX shell.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2009 07:35 AM
тАО01-08-2009 07:35 AM
Re: Shell Redirect error
You guys are right. I am not in real ksh when I did what Dennis told I found im not in korn shell im in c shell.
> akdkjak
akdkjak: Command not found.
> file $(whence tmboot)
Illegal variable name.
and if i do same in another server in ksh it works as you said.
now I think I will use
command >& file
tmboot -y > & $STARTLOG
coz i dont think I am supposed to change the shell or so whtever works if gud for me... and its working
thanks alot guys
you guys are brilliant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2009 08:22 AM
тАО01-08-2009 08:22 AM
Re: Shell Redirect error
tmboot -y > & filename
its says
ksh: syntax error: `&' unexpected
Im wondering why this is happenning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2009 08:37 AM
тАО01-08-2009 08:37 AM
Re: Shell Redirect error
> tmboot -y > & filename
No, you want either:
tmboot -y > filename
or:
tmboot -y 2> filename
or:
tmboot -y filename 2>&1
The first redirects STDOUT to filename. The second redirects STDERR to filename. The third redirects both STDOUT and STDERR to filename (as you originally had).
The manpages for 'ksh' or for 'sh-poxix' describe redirection.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2009 08:59 AM
тАО01-08-2009 08:59 AM
Re: Shell Redirect error
tmboot -y > $STARTLOG 2>&1
--> ambigious output redirect
this dint work coz script is running in the server using c shell and thats why I changed to
tmboot -y >& filename now it says & unexpected. which I believe is the correct syntax for c shell. Im really conufused now whats going on here. there is no other way to put output of the command tmboot -y to that file $STARTLOG other than what we have discussed here before.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2009 10:03 AM
тАО01-08-2009 10:03 AM
Re: Shell Redirect error
Oh, you need to run your script as a 'csh' (yuk!). Do this (thank Tom, [from the original link I cited] not me!):
cat .sillycsh
#!/usr/bin/csh
set LOG="/tmp/something_`(date '+%Y%m%d_%X')`"
sh -c "lvlnboot -y > ${LOG} 2>&1"
echo "see: ${LOG}"
...I used 'lvlnboot' since I don't have your executable :-)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2009 10:56 AM
тАО01-08-2009 10:56 AM
Re: Shell Redirect error
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1298982
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2009 11:25 AM
тАО01-08-2009 11:25 AM
Re: Shell Redirect error
You shouldn't have a space: >&
>it says
ksh: syntax error: `&' unexpected
Now you are using a real shell. Please put the syntax back and remove all occurrences of the scummy C shell.
If you have a script the first line will indicate the interpreter:
#!/usr/bin/ksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2009 12:39 PM
тАО01-08-2009 12:39 PM
Re: Shell Redirect error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2009 01:42 PM
тАО01-12-2009 01:42 PM