Redirection using csh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Redirection using csh
# 1  
Old 01-18-2010
Redirection using csh

I have a csh script which I am using to run a program

Code:
  set data   = $argv[1]
  set inmod  = $argv[2]
  set nxz    = $argv[3]

# Remove the file extension .pmod

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

# Run the program tdarwin
 
/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 > $fout.log

I am trying to redirect the output to a file $fout.log but I'm not getting anything.

Trying to do something like below does not work

Code:
/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-30-2010
If you just run:
Code:
/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

Do you get anything written to the screen?
# 3  
Old 01-30-2010
Hi.

If you intend to use csh, you need to know the limitations. In this specific instance, see the very first section of Csh Programming Considered Harmful ... cheers, drl
# 4  
Old 01-31-2010
Yes, I get everything on the screen working fine when I don't redirect.
# 5  
Old 01-31-2010
Shoule be okay, the only thing I can think of is to check what noclobber is set to?

See noclobber in:
Man Page for csh (OpenSolaris Section 1) - The UNIX and Linux Forums
# 6  
Old 01-31-2010
Hi.

Quote:
Originally Posted by kristinu
I have a csh script which I am using to run a program
...
Code:
...
    vrb=high 2>&1 | tee $fout.log

In a csh script, what happens when you run:
Code:
echo one
echo two 2>&1

Best wishes ... cheers, drl
# 7  
Old 02-01-2010
[quote]
In a csh script, what happens when you run:

Code:
echo one
echo two 2>&1

[quote]

No difference at all, because no error message was generated!

If you ran:
Code:
tony@tony-laptop:~$ ls -l fred > /tmp/logfile
ls: cannot access fred: No such file or directory
tony@tony-laptop:~$ cat /tmp/logfile

Then the listing of fred (if it had existed) would have gone into /tmp/logfile, that is stdout, file handle 1.
The error message is sent to stderr, file handle 2, allowing the user to see it even though stdout was sent to a log file.

If you then run:
Code:
tony@tony-laptop:~$ ls -l fred > /tmp/logfile 2>&1
tony@tony-laptop:~$ cat /tmp/logfile
ls: cannot access fred: No such file or directory
tony@tony-laptop:~$

Then the 2>&1 has redirected stderr to stdout, stdout was sent to /tmp/logfile so the error message also goes to /tmp/logfile.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. UNIX for Dummies Questions & Answers

about different redirection

explain the redirections 1>, 2>, 3>, ..... and 1< ,2<,3<..... where we use these things thanks Thread moved from AIX forum (2 Replies)
Discussion started by: tsurendra
2 Replies

3. Shell Programming and Scripting

Redirection

Hello All, I am using the below script to gather various tools running by the user, we have more than 100 tools running on the server so my challenge is to redirect memory & cpu load to the file with the name of the tool.so am using the below script i am stucking how to redirect to the file... (2 Replies)
Discussion started by: ajaincv
2 Replies

4. Shell Programming and Scripting

I/O redirection

Hello everyone,I'm reading a book and there's code fragment: exec 3>&1 ls -l 2>&1 >&3 3>&- | grep bad 3>&- exec 3>&- It says that the red part of that code does not close fd 3 but the green does close the fd 3.I can't understand that.....Why?Any predicate will be appreciated.:) (18 Replies)
Discussion started by: homeboy
18 Replies

5. UNIX for Dummies Questions & Answers

Help with Redirection

Hi Guys, I m new to UNIX and new to this forum. Was wondering if someone can help me understand redirection (standard input output pipeline etc) for starters, not too sure what this would mean who | sort > sortedfile | pr | lp im starting to understand common commands but when throwing... (2 Replies)
Discussion started by: jmack123
2 Replies

6. Shell Programming and Scripting

csh failing to call an 2 embedded csh script

I have an extraordinary problem with a csh script.....(feel free to berate the use of this but I'm modifying an existing bunch of them) Anyway, I have a master csh script which in turn calls a second csh script. This second csh script is below. Within this second script are two compiled C++... (1 Reply)
Discussion started by: pollsizer
1 Replies

7. Shell Programming and Scripting

redirection

Hi, The code below works, it's a part of a bash shell script that serve to search a pattern $pattern_da_cercare in the files contained in a directory $directory_iniziale. Now the proble is: How can I redirect stderr to a file? PS: so I want to redirect ALL the errors to a file. I tryed... (9 Replies)
Discussion started by: DNAx86
9 Replies

8. Shell Programming and Scripting

csh stderr redirection

Hi everyone, Simple scripting question here. I have: #!/bin/csh if ( -e $HOME/*.core) then rm -f $HOME/*.core >& /dev/null else echo "No core files to delete." endif But I keep getting the /home/user/*.core: no match dialog. How can I suppress this? or, why is... (0 Replies)
Discussion started by: jolok
0 Replies

9. Shell Programming and Scripting

stderr redirection in csh script

Man pages....look at the man pages. If you don't have them, you can find them on-line. Read them when you have nothing better to do. Find new commands and new ways of doing things. The answer: The only way to direct the standard output and standard error separately is by invoking... (0 Replies)
Discussion started by: thehoghunter
0 Replies

10. Programming

Help with redirection

Here is my problem. I don't know make this redirection thing work. The output file (called output.c) looks like this #include<stdio.h> int main() { int k; int m; print f("%d\n", k); printf("%d\n", m); return 0; } the input file(called input.c) is this #include<stdio.h> int... (2 Replies)
Discussion started by: Shallon1
2 Replies
Login or Register to Ask a Question