Re: output redirection with process substitution asynchronous?
On Dec 4, 9:28 am, pjodrr pjo...@gmail.com wrote: Hello, how can I prefix every line of output of some command with a timestamp? I thought like this: $ exec 3 (while read line; do echo $(date): $line; done) $ seq 4 3 Friday, December 4, 2009 4:20:29 PM MET: 1 $ Friday, December 4, 2009 4:20:29 PM MET: 2 Friday, December 4, 2009 4:20:29 PM MET: 3 Friday, December 4, 2009 4:20:29 PM MET: 4 please note that the prompt ($) returns before the command completes. Why is the process substitution asynchronous? Does anybody know of a better way to accomplish this? Thanks, Peter This should be in gnu.bash rather than gnu.bash.bug Would this work for you? while read line; do echo $(date): $line $((num++)); done
Re: output redirection with process substitution asynchronous?
pjodrr wrote: Hello, how can I prefix every line of output of some command with a timestamp? I thought like this: $ exec 3 (while read line; do echo $(date): $line; done) $ seq 4 3 Friday, December 4, 2009 4:20:29 PM MET: 1 $ Friday, December 4, 2009 4:20:29 PM MET: 2 Friday, December 4, 2009 4:20:29 PM MET: 3 Friday, December 4, 2009 4:20:29 PM MET: 4 please note that the prompt ($) returns before the command completes. Why is the process substitution asynchronous? Does anybody know of a better way to accomplish this? What's wrong with seq 4 | while read line; do echo $(date): $line; done
Re: output redirection with process substitution asynchronous?
On Dec 4, 12:58 pm, pk p...@pk.invalid wrote: pjodrr wrote: Hello, how can I prefix every line of output of some command with a timestamp? I thought like this: $ exec 3 (while read line; do echo $(date): $line; done) $ seq 4 3 Friday, December 4, 2009 4:20:29 PM MET: 1 $ Friday, December 4, 2009 4:20:29 PM MET: 2 Friday, December 4, 2009 4:20:29 PM MET: 3 Friday, December 4, 2009 4:20:29 PM MET: 4 please note that the prompt ($) returns before the command completes. Why is the process substitution asynchronous? Does anybody know of a better way to accomplish this? What's wrong with seq 4 | while read line; do echo $(date): $line; done It works for me. Does it not for you? If you're asking why not do it, then the answer is why call an external program unnecessarily?. Sorry, by the way, I missed what you were doing with the file descriptor on my first read. What is it that you're trying to accomplish? Are you doing this only to number the lines or is either seq or the while loop a stand-in for something else?
RFC: Letting bash print an XML syntax dump
Hi, bash folks, for a larger shell-based project I wanted to have definit answers to questions like - are all redirections to log handle 3 done when the log handle is actually open? - are all calls to grep handled properly (either return value or output ignored)? - are all calls to exit valid? Parsing shell syntax by means of Perl regexps turned to out to be hard and unreliable. So I added a new bash commandline option '--dump-syntax' that lets bash dump an XML-based syntax tree of the input script. The rest of the job was relatively easy using Perl and Perl-based XPath queries. (As a side-effect, bash also checks the syntax of process and command substitutions, what option -n would not do.) And now that I have my bashlint perl script I start getting adicted to it - every time I come across a stupid bug in my code I start thinking how bashlint could have detected that bug. I work for a closed-source software company and I would need extra paperwork to release the (bash-4.0-based) patch under the GPL. I already asked the bash maintainer (who found the idea interesting) and he proposed to ask the bash society for feedback before starting the paperwork. Please let me know what you think. Regards Jens Es weihnachtet sehr! Vom leckerem Backrezept bis zum leckeren Schneehasen finden Sie alles im Weihnachtsspecial von Arcor.de: http://www.arcor.de/rd/footer.weihnachten Feliz Navidad, God Yul, Merry X-Mas und ein frohes Fest! savelog Description: Binary data ?xml version=1.0 encoding=iso-8859-1? script simple line=81 w text=export/ w text=PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin/ /simple simple line=82 a name=COMPRESS text=quot;gzipquot;/ /simple simple line=83 a name=COMPRESS_OPTS text=quot;-9fquot;/ /simple simple line=84 a name=DOT_Z text=quot;.gzquot;/ /simple simple line=85 a name=DATUM text=`date +%Y%m%d%H%M%S` simple line=1 w text=date/ w text=+%Y%m%d%H%M%S/ /simple /a /simple simple line=88 a name=exitcode text=0/ /simple simple line=89 a name=prog text=`basename $0` simple line=1 w text=basename/ w text=$0/ /simple /a /simple simple line=90 a name=mode text=/ /simple simple line=91 a name=user text=/ /simple simple line=92 a name=group text=/ /simple simple line=93 a name=touch text=/ /simple simple line=94 a name=forceclean text=/ /simple simple line=95 a name=rolldir text=/ /simple simple line=96 a name=datum text=/ /simple simple line=97 a name=preserve text=/ /simple simple line=98 a name=hookscript text=/ /simple simple line=99 a name=quiet text=0/ /simple simple line=100 a name=rotateifempty text=yes/ /simple simple line=101 a name=count text=7/ /simple function funcname w text=usage/ /funcname funcbody group seq simple line=105 w text=echo/ w text=quot;Usage: $prog [-m mode] [-u user] [-g group] [-t] [-c cycle] [-p]quot;/ /simple simple line=106 w text=echo/ w text=quot; [-j] [-C] [-d] [-l] [-r rolldir] [-n] [-q] file ...quot;/ /simple simple line=107 w text=echo/ w text=quot; -m mode - chmod log files to modequot;/ /simple simple line=108 w text=echo/ w text=quot; -u user - chown log files to userquot;/ /simple simple line=109 w text=echo/ w text=quot; -g group - chgrp log files to groupquot;/ /simple simple line=110 w text=echo/ w text=quot; -c cycle - save cycle versions of the logfile (default: 7)quot;/ /simple simple line=111 w text=echo/ w text=quot; -r rolldir - use rolldir instead of . to roll filesquot;/ /simple simple line=112 w text=echo/ w text=quot; -C - force cleanup of cycled logfilesquot;/ /simple simple line=113 w text=echo/ w text=quot; -d - use standard date for rollingquot;/ /simple simple line=114 w text=echo/ w text=quot; -D - override date format for -dquot;/ /simple simple line=115 w text=echo/ w text=quot; -t - touch filequot;/ /simple simple line=116 w text=echo/ w text=quot; -l - donapos;t compress any log files (default: compress)quot;/ /simple simple line=117 w text=echo/ w text=quot; -p - preserve mode/user/group of original filequot;/ /simple simple line=118 w text=echo/ w text=quot; -j - use bzip2 instead of gzipquot;/ /simple simple line=119 w text=echo/ w text=quot; -x script - invoke script with rotated log file in \$FILEquot;/ /simple simple line=120 w text=echo/ w text=quot; -n - do not rotate empty filesquot;/ /simple simple line=121 w text=echo/ w text=quot; -q - suppress rotation messagequot;/ /simple simple line=122 w text=echo/ w text=quot; file - log file namesquot;/ /simple /seq /group /funcbody /function function funcname w text=fixfile/ /funcname funcbody group seq
functions can be created with dotted name but not removed
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 -Wall uname output: Linux e521 2.6.30-2-686 #1 SMP Sat Sep 26 01:16:22 UTC 2009 i686 GNU/Linux Machine Type: i486-pc-linux-gnu Bash Version: 4.0 Patch Level: 28 Release Status: release Description: A bash function with a dot in its name can be created and used with no problems but cannot be removed - the unset command chokes on the name. Repeat-By: This sequence yields the expected results: function f() { echo $FUNCNAME ; } f unset f ...while this sequence fails during the unset phase with the complaint that the name is not a valid identifier: function f.dot() { echo $FUNCNAME ; } f.dot unset f.dot
functions can be created with dotted name but not removed
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 -Wall uname output: Linux e521 2.6.30-2-686 #1 SMP Sat Sep 26 01:16:22 UTC 2009 i686 GNU/Linux Machine Type: i486-pc-linux-gnu Bash Version: 4.0 Patch Level: 28 Release Status: release Description: A bash function with a dot in its name can be created and used with no problems but cannot be removed - the unset command chokes on the name. Repeat-By: This sequence yields the expected results: function f() { echo $FUNCNAME ; } f unset f ...while this sequence fails during the unset phase with the complaint that the name is not a valid identifier: function f.dot() { echo $FUNCNAME ; } f.dot unset f.dot
output redirection with process substitution asynchronous?
Hello, how can I prefix every line of output of some command with a timestamp? I thought like this: $ exec 3 (while read line; do echo $(date): $line; done) $ seq 4 3 Friday, December 4, 2009 4:20:29 PM MET: 1 $ Friday, December 4, 2009 4:20:29 PM MET: 2 Friday, December 4, 2009 4:20:29 PM MET: 3 Friday, December 4, 2009 4:20:29 PM MET: 4 please note that the prompt ($) returns before the command completes. Why is the process substitution asynchronous? Does anybody know of a better way to accomplish this? Thanks, Peter
Re: functions can be created with dotted name but not removed
Michael O'Donnell wrote: A bash function with a dot in its name can be created and used with no problems but cannot be removed - the unset command chokes on the name. Repeat-By: This sequence yields the expected results: function f() { echo $FUNCNAME ; } f unset f ...while this sequence fails during the unset phase with the complaint that the name is not a valid identifier: function f.dot() { echo $FUNCNAME ; } f.dot unset f.dot Try unset -f f.dot
Options for IPC between bash processes under cygwin
I'd like to dispatch commands from one light-weight bash process to a longer running bash process which takes longer to initialize [ I have a _big_ library of bash functions ]. On Linux or any reasonable OS, I could do this remote dispatch easily with named pipes, but these don't exist on cygwin. I'd be interested to know if there are any good solutions to this problem already in existence. jon.
Re: functions can be created with dotted name but not removed
On Dec 4, 9:25 am, Michael O'Donnell mod.bash...@b0rken.com wrote: Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 -Wall uname output: Linux e521 2.6.30-2-686 #1 SMP Sat Sep 26 01:16:22 UTC 2009 i686 GNU/Linux Machine Type: i486-pc-linux-gnu Bash Version: 4.0 Patch Level: 28 Release Status: release Description: A bash function with a dot in its name can be created and used with no problems but cannot be removed - the unset command chokes on the name. Repeat-By: This sequence yields the expected results: function f() { echo $FUNCNAME ; } f unset f ...while this sequence fails during the unset phase with the complaint that the name is not a valid identifier: function f.dot() { echo $FUNCNAME ; } f.dot unset f.dot I can confirm that this behavior is also present in 3.2.49(23)-release and 4.0.33(1)-release.
Re: Options for IPC between bash processes under cygwin
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Jon Seymour on 12/4/2009 4:00 PM: On Linux or any reasonable OS, I could do this remote dispatch easily with named pipes, but these don't exist on cygwin. That's where you're wrong. Named pipes DO exist on cygwin, although there are still some bugs being hammered out when trying to have multiple simultaneous writers to a named pipe. Also, whereas you can do pipe on Linux, that won't work on cygwin (where named pipes must be read-only owr write-only). - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAksZr0AACgkQ84KuGfSFAYBnbgCeMS9E6jFwocHi4WbOBKk+OTmH G/0AoNZjXu/8oytboSqzbX2VIW9i1UIb =PKzk -END PGP SIGNATURE-
Re: Options for IPC between bash processes under cygwin
Oh, cool. Thanks for correcting me! jon. On Sat, Dec 5, 2009 at 11:54 AM, Eric Blake e...@byu.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Jon Seymour on 12/4/2009 4:00 PM: On Linux or any reasonable OS, I could do this remote dispatch easily with named pipes, but these don't exist on cygwin. That's where you're wrong. Named pipes DO exist on cygwin, although there are still some bugs being hammered out when trying to have multiple simultaneous writers to a named pipe. Also, whereas you can do pipe on Linux, that won't work on cygwin (where named pipes must be read-only owr write-only). - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAksZr0AACgkQ84KuGfSFAYBnbgCeMS9E6jFwocHi4WbOBKk+OTmH G/0AoNZjXu/8oytboSqzbX2VIW9i1UIb =PKzk -END PGP SIGNATURE-
Re: functions can be created with dotted name but not removed
Michael O'Donnell wrote: Bash Version: 4.0 Patch Level: 28 Release Status: release Description: A bash function with a dot in its name can be created and used with no problems but cannot be removed - the unset command chokes on the name. It's true -- the shell allows you to define a function with an invalid name containing a dot (in retrospect, probably not the wisest choice). Since `unset' without options assumes it is unsetting a variable, and bash doesn't allow you to create a variable whose name contains a dot, you need to tell unset you're removing a function: `unset -f f.dot'. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/