ksh equivalent to >& in csh

In csh I am using >&. What is the equivalent in ksh??

>&      - redirect stdout and stderr (csh,tcsh) 
2>&1 > ...

Thank you.

One last thing. I am running a program called tdarwin and outputting a log file using |& tee in csh as

tdarwin |& tee $fdrwlog

What would be the equivalent in ksh in this case?

tdarwin 2>&1 | tee $fdrwlog

What what be the difference between the two statements below

tdarwin 2>&1 > $fdrwlog

tdarwin 2>&1 | tee $fdrwlog

The statement below is still outputting the stuff to the terminal

tdarwin 2>&1 > $fdrwlog

tdarwin 2>&1 | tee $fdrwlog is working great, however no log file is created using tdarwin 2>&1 > $fdrwlog

Depending on the OS it may be reversed
> ... 2>&1 (SunOS for example)
2>&1 > ... (HP-UX for example)

I'm using Fedora 8

command > filename 2>&1

Apples and oranges.

$ cat myTest
echo OUTPUT
echo ERROR >&2
 
$ > file1 ./myTest 2>&1
$ cat file1
OUTPUT
ERROR
 
$ 2>&1 > file1 ./myTest
ERROR
$ cat file1
OUTPUT
 

I have a ksh script to which I pass an argument

tdradon -fdsstmod=npt02-sr40-syn-4x3smp.cmod

I have coded these variants like below, with the results following

  opt=$(print $arg | awk 'BEGIN {FS="="} {print $1}')
  print "opt1 = $arg $opt"
  opt=` print $arg | awk 'BEGIN {FS="="} {print $1}' `
  print "opt2 = $arg $opt"
  opt=` print $arg | awk 'BEGIN {FS="="} {print $1}' `
  print "opt3 = $arg $opt"
  opt=` echo "-fdsstmod=npt02-sr40-syn-4x3smp.cmod"  \
        | awk 'BEGIN {FS="="} {print $1}' `
  print "opt4 = $arg $opt"
opt1 = -fdsstmod=npt02-sr40-syn-4x3smp.cmod dsstmod
opt2 = -fdsstmod=npt02-sr40-syn-4x3smp.cmod dsstmod
opt3 = -fdsstmod=npt02-sr40-syn-4x3smp.cmod dsstmod
opt4 = -fdsstmod=npt02-sr40-syn-4x3smp.cmod -fdsstmod

As one can see, for some reason the -f is removed and am only getting dsstmod when using print rather than -fdsstmod.

Huh ?
Have you anything to support that bizarre (to say the least) HP-UX theory ?

IMO it should be:

> ... 2>&1

also on HP-UX

Eeks. What a dumb mistake! :o

Good morning!

LOL, Morning! :smiley:

I remember having used that notation years ago at outsourcing service division of HP (don't remember the HP-UX version nor the Hardware on which it was) ... Or is it my brain which is betraying me ... already alzeimer ???
(a long time i haven't use HPUX)

If you used it on HPUX then that probably wasn't right. It is a quite common mistake, and often it does not get corrected, since the trouble is that it will only get noticed if there is an actual error message on stderr (and scripts do not always get tested properly). The only time one would use 2>&1 ... > is if stdout and stderr were pointing to different destinations before and you want to point stderr to where stdout is pointing before redirecting stdout to somewhere else.

I wasn't writting a script, i was fixing an existing script and the fix was to rewrite so.

So maybe it is my brain : i don't remember the exact context ... maybe the context was : an error unexpectedly logged into a log file ...

Oooops - good morning ! :smiley:

That would be the latter, welcome to the club :wink:
HP, like most others Unix vendors, is using System V ksh88 code (likely with custom patches). This code is processing the redirections in order they are found, like the traditional bourne shell, bash and all POSIX (more or less) compliant shells. Open Group: Shell Command Language (Redirections)
There is absolutely no reason for this standard way to be deliberately broken.
HP-UX: Command Separators

@jilliagre
Yep, i think i used it in a very specific context : the redirection were for sure working just the standard way. I guess it is just the expected result for that specific need that made me use the 2>&1 before, and it was so unusual and so far in my souvenir, this is what brought the confusion in my too little brain lol :slight_smile: