Using 2>&1 | tee $fout.login csh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using 2>&1 | tee $fout.login csh
# 1  
Old 01-19-2010
Using 2>&1 | tee $fout.login csh

I created this bash script. However when I tried to do it using csh, 2>&1 | tee $fout.log did not work.

Code:
#!/bin/bash

  data=$1
  inmod=$2
  nxz=$3

  data=` echo $data | awk 'BEGIN { FS=".dat" } { print $1 }' `
  inmod=` echo $inmod | awk 'BEGIN { FS=".vmod" } { print $1 }' `
  nx=` echo $nxz | awk 'BEGIN { FS="x" } { print $1 }' `
  nz=` echo $nxz | awk 'BEGIN { FS="x" } { print $2 }' `
  fout="${data}-${nx}x${nz}-drw"

/nethome/chrisd/Zollo/Chrisd/Tommy-0911/bin/tdarwin base=sunsp.base  \
    data=$data.dat param="P" intp="LIN" inmod=$inmod.vmod            \
    nlay=1 std=on nxp=$nx nzp=$nz npop=60 dtau=0.15 mdacc=0.1        \
    varp=1.0 sigma0=100.0 maxiter=200 maxitertp=10 tol=0.0           \
    outmod=$fout.vmod backup=$fout.bck expl=$fout.exp                \
    vrb=high 2>&1 | tee $fout.log

# 2  
Old 01-19-2010
Hello,

Quote:
However when I tried to do it using csh, 2>&1 | tee $fout.log did not work.
here's the bad news: you can't do that in csh. See for instance Csh Programming Considered Harmful. The relevant excerpt:

Quote:
Along these same lines, you can't direct error messages in csh scripts
out stderr as is considered proper. In the Bourne shell, you might say:

echo "$0: cannot find $file" 1>&2

but in the csh, you can't redirect stdout out stderr, so you end
up doing something silly like this:

sh -c 'echo "$0: cannot find $file" 1>&2'
Cheers,
Loïc
# 3  
Old 01-19-2010
I have used

Code:
|& tee $fout.log

Seems to work. What does everybody think of this?
# 4  
Old 01-19-2010
Quote:
Originally Posted by kristinu
I have used
Code:
     |& tee $fout.log

Seems to work. What does everybody think of this?
Yeah, in your case that should work. I concentrate on the 2>&1, but you're doing more than that: you then pipe to tee. AFAICS, this action is equivalent to |&

Cheers,
Loïc.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mindboggling difference between using "tee" and "/usr/bin/tee" in bash

I'm on Ubuntu 14.04 and I manually updated my coreutils so that "tee" is now on version 8.27 I was running a script using bash where there is some write to pipe error at some point causing the tee command to exit abruptly while the script continues to run. The newer version of tee seems to prevent... (2 Replies)
Discussion started by: stompadon
2 Replies

2. 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

3. Shell Programming and Scripting

Linux csh script going to Suspended (tty output) when running with & (bg)

i have strange behavior i have csh file that run java process something like this : run_server.csh #!/usr/bin/tcsh java -Dtest=testparam -cp ${TEST}/lib/device.jar:${TEST}/conf:${TEST}/lib/commons-logging-1.1.1.jar com.device.server when i run it like this :... (7 Replies)
Discussion started by: umen
7 Replies

4. Shell Programming and Scripting

>& redirection not working within csh script

I'm having a strange problem with basic >& output redirection to a simple log file in csh. When I run this particular output redirection on the command line, it works, but then when I run the same output redirection command >& in my c shell script, I get a blank log file. Nothing is output to the... (5 Replies)
Discussion started by: silencio
5 Replies

5. Shell Programming and Scripting

ksh equivalent to >& in csh

In csh I am using >&. What is the equivalent in ksh?? >& - redirect stdout and stderr (csh,tcsh) (18 Replies)
Discussion started by: kristinu
18 Replies

6. Shell Programming and Scripting

STDERR to file & terminal using tee

Hi All, Solarix/Bash v3x Im trying to output any standard errors created by the script to a file using the below command: . runDTE.sh 2> "$DTE_ERROR_FILE" however the errors do get written to the dir/file stored in $DTE_ERROR_FILE but the error does not appear on the terminal screen in... (4 Replies)
Discussion started by: satnamx
4 Replies

7. UNIX for Dummies Questions & Answers

FTP & login

Folks; Is there a way in UNIX to do the following: When users use FTP to login to a mounted drive on Solaris server, if that was their first time login a home directory for that user will be created & if the home directory exists it won't create a home directory (user should not have a login... (6 Replies)
Discussion started by: Katkota
6 Replies

8. 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

9. UNIX for Advanced & Expert Users

login & password

I bought a pentium 2 (office auction) for my country home. When I turned it on it had Unix. It asks me for a login and password. I don't have these and since I don't know Unix I want to reformat the drive or at least be able to install Windows. I can't get past the Login and password promt. Anyone... (8 Replies)
Discussion started by: cab
8 Replies

10. UNIX for Advanced & Expert Users

remote startup of login & sessions

Hello All, I would like to know if anyone has done or has information on how to start a workstation up form another remote station. For example I am sitting at station A and I want to start up a session on station B, setting display to output on station B "0.0". Here is the tricky part station... (2 Replies)
Discussion started by: larry
2 Replies
Login or Register to Ask a Question