ksh equivalent to >& in csh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh equivalent to >& in csh
# 8  
Old 11-04-2010
Code:
command > filename 2>&1

# 9  
Old 11-04-2010
Quote:
Originally Posted by kristinu
What what be the difference between the two statements below

Code:
# Sends standard error to standard output (the screen)
# and then sends standard output to a file (standard error
# still goes to the screen)
tdarwin 2>&1 > $fdrwlog
 
# Send standard error to standard output (the screen)
# then sends both to the file and to the screen
tdarwin 2>&1 | tee $fdrwlog

The statement below is still outputting the stuff to the terminal

Code:
tdarwin 2>&1 > $fdrwlog

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

Quote:
Originally Posted by ctsgnb
Depending on the OS it may be reversed
> ... 2>&1 (SunOS for example)
2>&1 > ... (HP-UX for example)
Apples and oranges.

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

# 10  
Old 11-04-2010
I have a ksh script to which I pass an argument

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

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

Code:
  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"

Code:
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.
# 11  
Old 11-04-2010
Quote:
Originally Posted by ctsgnb
Depending on the OS it may be reversed
> ... 2>&1 (SunOS for example)
2>&1 > ... (HP-UX for example)
Huh ?
Have you anything to support that bizarre (to say the least) HP-UX theory ?
# 12  
Old 11-05-2010
Quote:
Originally Posted by scottn
Code:
2>&1 > ...

Quote:
Originally Posted by ctsgnb
Depending on the OS it may be reversed
> ... 2>&1 (SunOS for example)
2>&1 > ... (HP-UX for example)
IMO it should be:
Code:
> ... 2>&1

also on HP-UX

Last edited by Scrutinizer; 11-05-2010 at 02:52 AM..
# 13  
Old 11-05-2010
Quote:
Originally Posted by scottn
Code:
2>&1 > ...

Eeks. What a dumb mistake! Smilie

Good morning!
# 14  
Old 11-05-2010
LOL, Morning! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

>& >&! in /bin/csh

i am new player in linux what does mean ">& and >&!" in script or command line? thanks (4 Replies)
Discussion started by: abdossamad2003
4 Replies

2. Shell Programming and Scripting

Expect : what is the equivalent to ksh if -s

In Ksh to check if file exists and is non zero .. if ; then echo "Error $FILE does not exists!" else echo "$FILE found!" fi Cant seem to find the Expect equivalent .... Any help is greatly appreciated. (2 Replies)
Discussion started by: popeye
2 Replies

3. Shell Programming and Scripting

Equivalent of set -o vi in csh

Hi, I am working with two shells on two different users. one is on ksh and one is on csh. In ksh I use set -o vi and I am able to see my history commands by typing esc,- keys. I want the same feature in csh as well how can I do that. Regards, Venkat (3 Replies)
Discussion started by: svenkatareddy
3 Replies

4. Shell Programming and Scripting

equivalent of backspace in ksh

Hello All, What would be the equivalent of backspace key in the korn shell. My scenario is: I am trying to install a product..and it comes out with a Licence Agreement screen, When I manually enter backspace key..I am able to get out of the whole agreement message to a point to type Agree A) or... (2 Replies)
Discussion started by: solaix14
2 Replies

5. Shell Programming and Scripting

How to define array in Bourne shell , csh & ksh

Dear friends... Kindly if any one can help me to know the differences in definning & retreiving data from arrays in the sh,csh & ksh. I always facing problems in this issue. thanks...:) BR (3 Replies)
Discussion started by: ahmad.diab
3 Replies

6. Shell Programming and Scripting

what is ksh equivalent of bash echo -n ?

Hi folks, I need to stop printing a new line after echoing a string in KSH. i know bash provides echo -n "string" what is the ksh equivalent for this ? (3 Replies)
Discussion started by: mudhireddy
3 Replies

7. UNIX for Dummies Questions & Answers

Csh Vs Ksh

I created a simple script and attempted to run it. All that the scrip contained was "ls -l". At first I received the message "ksh: run_dir: not found" I then tried typing "csh run_dir" This time the script worked. typing echo $SHELL produced /bin/ksh I would like to understand why this... (4 Replies)
Discussion started by: SUSANR9999
4 Replies

8. Shell Programming and Scripting

Exactly How can we define "sh ksh csh &bash"

Hi - I m prashant. I m new in UNIX&LINUX world. I want to ask that how can we define the shell in Linux like bash,ksh,csh in Linux. What is the use of these shells. I know there are mny experts on net if you can tell me then please do me this favour and tell me about this topic. ... (1 Reply)
Discussion started by: prashantsingh
1 Replies

9. Shell Programming and Scripting

\!* in csh what is it for ksh

Hey guys, Hopefully a simple question for you. In csh I have an alias that looks like: alias ff 'find . -name \!* -print' and can therefore perform a search for a file by typing: ff filename The same comand does not work in ksh alias ff="find . -name \!* -print" I get: find:... (3 Replies)
Discussion started by: timsk
3 Replies

10. Shell Programming and Scripting

Perl equivalent of ksh if / echo statement

Is there an equivalent perl statement for the following ksh statement ? example if then ... else ... fi (2 Replies)
Discussion started by: gefa
2 Replies
Login or Register to Ask a Question