Sponsored Content
Top Forums Shell Programming and Scripting tcsh - understanding difference between "echo string" and "echo string > /dev/stdout" Post 302668597 by marcink on Monday 9th of July 2012 03:01:53 PM
Old 07-09-2012
Quote:
Originally Posted by shamrock
The first line "Redirected to STDOUT" which you expect to show up in the file mystdout got overwritten by the last one "Should default to STDOUT without redirection"...and this will happen with any sh not just the tcsh...and by appending to mystdout you will see both the lines there...
Code:
./out_to_streams.csh >> mystdout

Tried it and I get the same result. I've tried "append redirect" (i.e. ">>") on the command line as suggested, and it did not work. I changed it in the script as well:
Code:
#!/bin/tcsh -f

echo Redirected to STDOUT >> /dev/stdout
echo Redirected to STDERR >> /dev/stderr

echo Should default to STDOUT without redirection

And "Redirect to STDOUT" still gets lost. I've tried all four combinations (i.e. ">" vs ">>" in script and on command line), and in all cases "Redirect to STDOUT" gets lost.

Is there some bizarre handling of the IO streams and redirects in tcsh that can explain this behavior?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

input string="3MMTQSZ348GGMZRQWMJM4SD6M";output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6

input string="3MMTQSZ348GGMZRQWMJM4SD6M" output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6M" using linux shell script (4 Replies)
Discussion started by: pankajd
4 Replies

2. Shell Programming and Scripting

"sed" to check file size & echo " " to destination file

Hi, I've modified the syslogd source to include a thread that will keep track of a timer(or a timer thread). My intention is to check the file size of /var/log/messages in every one minute & if the size is more than 128KB, do a echo " " > /var/log/messages, so that the file size will be set... (7 Replies)
Discussion started by: jockey007
7 Replies

3. Shell Programming and Scripting

Difference between using "echo" builtin and /bin/echo

So in my shell i execute: { while true; do echo string; sleep 1; done } | read line This waits one second and returns. But { while true; do /bin/echo string; sleep 1; done } | read line continues to run, and doesn't stop until i kill it explicitly. I have tried this in bash as well as zsh,... (2 Replies)
Discussion started by: ulidtko
2 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

6. AIX

echo $varibla | mail -s "subject" "xxx@xxx.com" not ruuning as expected

Hi Folks, As per the subject, the following command is not working as expected. echo $variable | mail -s "subject" "xxx@xxx.com" Could anyone figure it out whats wrong with this. I am using AIX box. Regards, (2 Replies)
Discussion started by: gjarms
2 Replies

7. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

8. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

9. Shell Programming and Scripting

About reture with string and keep other "echo" info

I use below code to get ip, and I want to echo something in the function, but the $IP will be all the value from "echo" I just want to get the real ip, and keep the echo info, any help #!/bin/bash get_ip() { ip=$(grep -B2 "00:01:02:03:04:05" ip_tmp.log |head -1 |awk '{print $2}') ... (4 Replies)
Discussion started by: yanglei_fage
4 Replies

10. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies
PEGASUS-EXITCODE(1)													       PEGASUS-EXITCODE(1)

NAME
pegasus-exitcode - Checks the stdout/stderr files of a workflow job for any indication that an error occurred in the job. This script is intended to be invoked automatically by DAGMan as the POST script of a job. SYNOPSIS
pegasus-exitcode [-h][-t n][-r rv][-n] job.out DESCRIPTION
pegasus-exitcode is a utility that examines the STDOUT of a job to determine if the job failed, and renames the STDOUT and STDERR files of a job to preserve them in case the job is retried. Pegasus uses pegasus-exitcode as the DAGMan postscript for all jobs submitted via Globus GRAM. This tool exists as a workaround to a known problem with Globus where the exitcodes of GRAM jobs are not returned. This is a problem because Pegasus uses the exitcode of a job to determine if the job failed or not. In order to get around the exitcode problem, Pegasus wraps all GRAM jobs with Kickstart, which records the exitcode of the job in an XML invocation record, which it writes to the job's STDOUT. The STDOUT is transferred from the execution host back to the submit host when the job terminates. After the job terminates, DAGMan runs the job's postscript, which Pegasus sets to be pegasus-exitcode. pegasus-exitcode looks at the invocation record generated by kickstart to see if the job succeeded or failed. If the invocation record indicates a failure, then pegasus-exitcode returns a non-zero result, which indicates to DAGMan that the job has failed. If the invocation record indicates that the job succeeded, then pegasus-exitcode returns 0, which tells DAGMan that the job succeeded. pegasus-exitcode performs several checks to determine whether a job failed or not. These checks include: 1. Is STDOUT empty? If it is empty, then the job failed. 2. Are there any <status> tags with a non-zero value? If there are, then the job failed. Note that, if this is a clustered job, there could be multiple <status> tags, one for each task. If any of them are non-zero, then the job failed. 3. Is there at least one <status> tag with a zero value? There must be at least one successful invocation or the job has failed. In addition, pegasus-exitcode allows the caller to specify the exitcode returned by Condor using the --return argument. This can be passed to pegasus-exitcode in a DAGMan post script by using the $RETURN variable. If this value is non-zero, then pegasus-exitcode returns a non-zero result before performing any other checks. For GRAM jobs, the value of $RETURN will always be 0 regardless of whether the job failed or not. Also, pegasus-exitcode allows the caller to specify the number of successful tasks it should see using the --tasks argument. If pegasus-exitcode does not see N successful tasks, where N is set by --tasks, then it will return a non-zero result. The default value is 1. This can be used to detect failures in clustered jobs where, for any number of reasons, invocation records do not get generated for all the tasks in the clustered job. In addition to checking the success/failure of a job, pegasus-exitcode also renames the STDOUT and STDERR files of the job so that if the job is retried, the STDOUT and STDERR of the previous run are not lost. It does this by appending a sequence number to the end of the files. For example, if the STDOUT file is called "job.out", then the first time the job is run pegasus-exitcode will rename the file "job.out.000". If the job is run again, then pegasus-exitcode sees that "job.out.000" already exists and renames the file "job.out.001". It will continue to rename the file by incrementing the sequence number every time the job is executed. OPTIONS
-h, --help Prints a usage summary with all the available command-line options. -t n, --tasks n Number of tasks expected. If less than n tasks succeeded, then pegasus-exitcode will fail with a non-zero return value. This is used in cases where we may not get a Kickstart invocation record for some tasks. Normally Seqexec will detect failed Kickstart invocations and fail accordingly. -r rv, --return rv Return value reported by DAGMan. This can be specified in the DAG using the $RETURN variable. If this is non-zero, then pegasus-exitcode immediately fails with a non-zero return value itself. -n, --no-rename Don't rename job.out and job.err to .out.XXX and .err.XXX. This option is used primarily for testing. AUTHORS
Gideon Juve <juve@usc.edu> Pegasus Team http://pegasus.isi.edu 05/24/2012 PEGASUS-EXITCODE(1)
All times are GMT -4. The time now is 08:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy