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
Test::Output::Tie(3)					User Contributed Perl Documentation				      Test::Output::Tie(3)

NAME
Test::Output::Tie - module used by Test::Output to tie STDERR and STDOUT DESCRIPTION
You are probably more interested in reading Test::Output. This module is used to tie STDOUT and STDERR in Test::Output. Methods TIEHANDLE The constructor for the class. PRINT This method is called each time STDERR or STDOUT are printed to. PRINTF This method is called each time STDERR or STDOUT are printed to with "printf". FILENO BINMODE read This function is used to return all output printed to STDOUT or STDERR. AUTHOR
Currently maintained by brian d foy, "bdfoy@cpan.org". Shawn Sorichetti, "<ssoriche@cpan.org>" SOURCE AVAILABILITY
This module is in Github: http://github.com/briandfoy/test-output/tree/master COPYRIGHT &; LICENSE Currently maintained by brian d foy, "bdfoy@cpan.org". Copyright 2005-2008 Shawn Sorichetti, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. ACKNOWLEDGMENTS
This code was taken from Test::Simple's TieOut.pm maintained Michael G Schwern. TieOut.pm was originally written by chromatic. Thanks for the idea and use of the code. perl v5.16.2 2011-04-21 Test::Output::Tie(3)
All times are GMT -4. The time now is 07:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy