1753797 Members
6906 Online
108799 Solutions
New Discussion юеВ

Re: Shell Redirect error

 
SOLVED
Go to solution
Michael Mike Reaser
Valued Contributor

Re: Shell Redirect error

OK, since we're sure you're in the Korn shell, issue the commands

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.
There's no place like 127.0.0.1

HP-Server-Literate since 1979
pareshan
Regular Advisor

Re: Shell Redirect error

where tmboot
/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
Dennis Handly
Acclaimed Contributor

Re: Shell Redirect error

As JRF said, you are using the scummy C shell. It has that error: Ambiguous output redirect

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
Bill Hassell
Honored Contributor

Re: Shell Redirect error

You can change your login shell with one command:

chsh pareshan /usr/bin/sh

Now logout and log back in again. Your active shell will be a sane POSIX shell.


Bill Hassell, sysadmin
pareshan
Regular Advisor

Re: Shell Redirect error

Dennis & James,

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
pareshan
Regular Advisor

Re: Shell Redirect error

Now I have another problem when i do

tmboot -y > & filename

its says

ksh: syntax error: `&' unexpected

Im wondering why this is happenning.
James R. Ferguson
Acclaimed Contributor

Re: Shell Redirect error

Hi (again):

> 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...
pareshan
Regular Advisor

Re: Shell Redirect error

I think You dint get me. Thats what my problem is
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.


James R. Ferguson
Acclaimed Contributor

Re: Shell Redirect error

Hi (again) :

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...
OldSchool
Honored Contributor

Re: Shell Redirect error