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 screen, either.
It gets even stranger because the
output redirection works within my c shell script on Redhat Linux but not when I run my c shell script on my current operating system, CentOS V. 2.16.0 release 5.8.
Is there some system variable that needs to be set in CentOS V. 2.16.0 release 5.8, or why does
work in *every other situation* (both command line and running in my c shell script on some computers) except when running my csh script on CentOS V. 2.16.0 release 5.8? It should work the same within the cshell script on all computers, shouldn't it? And does anyone have a work-around that will successfully output to a log file in a csh script on CentOS V. 2.16.0 release 5.8?
EDIT: I was thinking maybe some system variable in CentOS V. 2.16.0 release 5.8 is buffering output from csh? I have no idea, though.
Does your C shell script start with #!/bin/csh?
Furthermore, redirection in C shell might fail if the redirected expression exceeds a certain level of complexity.
It should work the same within the cshell script on all computers, shouldn't it?
Not necessarily. Even computers running exactly the same operating system may not be running the same version of csh - it's just an installed program, which may or may not be the one that shipped with the OS.
Does anyone else has any familiarity with this problem? Namely why basic text output will redirect with >& on the command line / console but not within my cshell script on this particular version of CentOS?
MadeInGermany, yes my script begins with #!/bin/csh and my program doesn't make complex output - the output is very basic - 3 lines of text - the first line is blank and then the second 2 lines have text output.
>& works in my cshell script on several other computers with different OS/versions but not on this version and I can't figure out why. I need some way to redirect output within my cshell script that doesn't involve software upgrades/installs (I work at a corporation and don't have install permissions).
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)
I have a simple script which will send a curl request and redirect the output to a log file.
for i in {1..20}
do
curl google.com -is >>log.log &
echo "request # $i" >> log.log
doneAfter it completes the execution, if I run the following command I should see 20 lines because I am printing... (4 Replies)
I need to count the number of lines in a .txt file and put it in a variable.
I am using the following code
#!/bin/bash
count = $(wc -l "some file.txt" | awk '{print$1}')
echo $count
It is giving the following error.
line3: count: command not foundWhat am I doing wrong here? :confused: (7 Replies)
I have a csh script which I am using to run a program
set data = $argv
set inmod = $argv
set nxz = $argv
# Remove the file extension .pmod
set data = ` echo $data | awk 'BEGIN { FS=".dat" } { print $1 }' `
set inmod = ` echo $inmod | awk 'BEGIN { FS=".vmod" } { print... (8 Replies)
I am using perl to perform a search and replace. It works at the command line, but not in the csh shell script
perl -pi -e 's@/Pattern@@g' $path/$file
I used the @ as my delimiter because the pattern contains "/" (3 Replies)
Portion of my script below :
if ; then
NUMBEROFFEILDS=`cat ${BASE_SCRIPT_LOC}/standardfilecleanup.lst|grep -w ${db_file_path}|awk -F: '{print NF}'`
COUNT=4
while ; do
awk_var="$"`echo $COUNT`
file_name1=`cat ${BASE_SCRIPT_LOC}/standardfilecleanup.lst|grep -w... (1 Reply)
Here is my script
#!/bin/bash
pwd
cd /var/lib/pgsql
Both "pwd" and "cd" are not executed is there any other way i can change the current working directory to /var/lib/pgsql pls help! (9 Replies)
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)
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)