Sponsored Content
Full Discussion: Redirecting stdout problem
Top Forums Shell Programming and Scripting Redirecting stdout problem Post 302659319 by radoulov on Wednesday 20th of June 2012 05:20:05 PM
Old 06-20-2012
Yes,
the open file descriptors that refer to the deleted file remain (there will be an unnamed file).

Consider the following example (this is on Linux):

Code:
zsh-4.3.17[t]% zsh -c 'while :; do sleep 3;date ; done > outfile'&
[1] 1470
zsh-4.3.17[t]% ls -l /proc/1470/fd
total 0
lrwx------ 1 drado drado 64 Jun 20 23:08 0 -> /dev/pts/2
l-wx------ 1 drado drado 64 Jun 20 23:08 1 -> /home/drado/t/outfile
lrwx------ 1 drado drado 64 Jun 20 23:08 10 -> /dev/pts/2
lr-x------ 1 drado drado 64 Jun 20 23:08 11 -> /dev/null
lrwx------ 1 drado drado 64 Jun 20 23:08 12 -> /dev/pts/2
lrwx------ 1 drado drado 64 Jun 20 23:08 2 -> /dev/pts/2
zsh-4.3.17[t]% tail -f /home/drado/t/outfile
Wed Jun 20 23:08:08 CEST 2012
Wed Jun 20 23:08:11 CEST 2012
Wed Jun 20 23:08:14 CEST 2012
Wed Jun 20 23:08:17 CEST 2012
Wed Jun 20 23:08:20 CEST 2012
Wed Jun 20 23:08:23 CEST 2012
^C
zsh-4.3.17[t]% rm /home/drado/t/outfile
zsh-4.3.17[t]% tail -f /home/drado/t/outfile
tail: cannot open `/home/drado/t/outfile' for reading: No such file or directory
zsh-4.3.17[t]% tail -f /proc/1470/fd/1
Wed Jun 20 23:08:14 CEST 2012
Wed Jun 20 23:08:17 CEST 2012
Wed Jun 20 23:08:20 CEST 2012
Wed Jun 20 23:08:23 CEST 2012
Wed Jun 20 23:08:26 CEST 2012
Wed Jun 20 23:08:29 CEST 2012
Wed Jun 20 23:08:32 CEST 2012
Wed Jun 20 23:08:35 CEST 2012
Wed Jun 20 23:08:39 CEST 2012
Wed Jun 20 23:08:42 CEST 2012
Wed Jun 20 23:08:45 CEST 2012
^C
zsh-4.3.17[t]% lsof -p1470|fgrep outf
zsh     1470 drado    1w   REG  252,0      630  261137 /home/drado/t/outfile (deleted)
zsh-4.3.17[t]% kill -9 %1
zsh-4.3.17[t]%
[1]  + killed     zsh -c 'while :; do sleep 3;date ; done > outfile'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

redirecting STDOUT & STDERR

In bash, I need to send the STDOUT and STDERR from a command to one file, and then just STDERR to another file. Doing one or the other using redirects is easy, but trying to do both at once is a bit tricky. Anyone have any ideas? (9 Replies)
Discussion started by: jshinaman
9 Replies

2. Shell Programming and Scripting

implicitly redirecting stdout to a file

Is there a way to redirect all stdout to a file implicitly - like defining stdout=/home/me/process.log - so that all "echo" commands in several scripts/subscripts are written to that file; instead of having to edit all scripts to redirect the "echo" (e.g. echo 'This is a test ' >>... (1 Reply)
Discussion started by: ALTRUNVRSOFLN
1 Replies

3. Shell Programming and Scripting

Redirecting part of output to stdout

Hi, I am trying to execute a command like this: find ./ -name "*.gz" -exec sh -c 'zcat {} | awk -f parse.awk' \; >> output If I want to print the filename, i generally use the -print argument to the find command but when I am redirecting the output to a file, how can I print just the... (2 Replies)
Discussion started by: Legend986
2 Replies

4. UNIX for Dummies Questions & Answers

Redirecting several outputs to /dev/stdout

I have an executable that, depending on its input, outputs to either one file or several. It usually prints nothing on screen. The usual way to call this program is to specify an input and output filenames, like this: ./executable.exe -i inputfile -o outputfileIt will then try to use the output... (1 Reply)
Discussion started by: aplaydoc
1 Replies

5. Shell Programming and Scripting

redirecting to stdout in betwen command

can anyone help me in making singleline command for Capital Letters are folders ,small letter are files X,Y,Z are subfolders of A as shown below A - X,Y,Z Folder X has three files a.txt,b.txt,c.txt similarly Y,Z. as shown below X- a.txt,b.txt,c.txt Y- a.txt,b.txt,c.txt Z-... (4 Replies)
Discussion started by: phoenix_nebula
4 Replies

6. Shell Programming and Scripting

Redirecting stdout to variable while printing it

Hi everybody, I am trying to do the thing you see in the title, and I can't simply do a=$(svn up) echo $a because the program (svn) gives output on lots of lines and in the variable the output is stored on only one line (resulting in a horribly formatted text). Any tips? Thanks,... (2 Replies)
Discussion started by: ocirne94
2 Replies

7. Shell Programming and Scripting

Redirecting stdout on background task

Hello, I have a script (videostream.sh) which invokes the GStreamer command-line tool gst-launch with all the correct command line parameters. When I invoke this program, I add the '&' character at the end to make it a background task, so that my script can complete and exit, i.e. gst-launch... (1 Reply)
Discussion started by: salukibob
1 Replies

8. Shell Programming and Scripting

Redirecting stdout continously to a file

I have a C program that continously outputs info to stdout. The problem is that I am redirecting the stdout and stderr to a file and stdout is written at the end of the problem rather than continously to the file. This could be a problem if for example the program is killed and the stdout output is... (3 Replies)
Discussion started by: igurov
3 Replies

9. Shell Programming and Scripting

Redirecting stdion, stdout within an AT command

Hello, I'm strugling with some redirecting and all help is apreciated. The following program is working as expected, but the result of the AT command doesn't go to any file. Thanks in advance for the help. #!/bin/bash modem=/dev/ttyUSB1 file=/root/imsi.txt # print error to stderr and exit... (4 Replies)
Discussion started by: cleitao
4 Replies

10. UNIX for Dummies Questions & Answers

Redirecting stdout inside a loop

hi, OK. I am writing a bash script, and it is almost working for me. Problem 1: I currently have stout sent to a file (stout.miRNA.bash.$date_formatted) which I would like to have work inside my loop, but when I move it, it just prints to the screen. Problem 2: I have a second file... (18 Replies)
Discussion started by: hmortens
18 Replies
Date::Parse(3)						User Contributed Perl Documentation					    Date::Parse(3)

NAME
Date::Parse - Parse date strings into time values SYNOPSIS
use Date::Parse; $time = str2time($date); ($ss,$mm,$hh,$day,$month,$year,$zone) = strptime($date); DESCRIPTION
"Date::Parse" provides two routines for parsing date strings into time values. str2time(DATE [, ZONE]) "str2time" parses "DATE" and returns a unix time value, or undef upon failure. "ZONE", if given, specifies the timezone to assume when parsing if the date string does not specify a timezone. strptime(DATE [, ZONE]) "strptime" takes the same arguments as str2time but returns an array of values "($ss,$mm,$hh,$day,$month,$year,$zone)". Elements are only defined if they could be extracted from the date string. The $zone element is the timezone offset in seconds from GMT. An empty array is returned upon failure. MULTI-LANGUAGE SUPPORT Date::Parse is capable of parsing dates in several languages, these include English, French, German and Italian. $lang = Date::Language->new('German'); $lang->str2time("25 Jun 1996 21:09:55 +0100"); EXAMPLE DATES
Below is a sample list of dates that are known to be parsable with Date::Parse 1995:01:24T09:08:17.1823213 ISO-8601 1995-01-24T09:08:17.1823213 Wed, 16 Jun 94 07:29:35 CST Comma and day name are optional Thu, 13 Oct 94 10:13:13 -0700 Wed, 9 Nov 1994 09:50:32 -0500 (EST) Text in ()'s will be ignored. 21 dec 17:05 Will be parsed in the current time zone 21-dec 17:05 21/dec 17:05 21/dec/93 17:05 1999 10:02:18 "GMT" 16 Nov 94 22:28:20 PST LIMITATION
Date::Parse uses Time::Local internally, so is limited to only parsing dates which result in valid values for Time::Local::timelocal. This generally means dates between 1901-12-17 00:00:00 GMT and 2038-01-16 23:59:59 GMT BUGS
When both the month and the date are specified in the date as numbers they are always parsed assuming that the month number comes before the date. This is the usual format used in American dates. The reason why it is like this and not dynamic is that it must be deterministic. Several people have suggested using the current locale, but this will not work as the date being parsed may not be in the format of the current locale. My plans to address this, which will be in a future release, is to allow the programmer to state what order they want these values parsed in. AUTHOR
Graham Barr <gbarr@pobox.com> COPYRIGHT
Copyright (c) 1995-2009 Graham Barr. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. POD ERRORS
Hey! The above document had some coding errors, which are explained below: Around line 325: You forgot a '=back' before '=head1' perl v5.18.2 2009-12-12 Date::Parse(3)
All times are GMT -4. The time now is 08:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy