I have a problem with egrep command. When I execute my command in tcsh it is working perfect but when I execute it from tcl script or in tclsh, I got:
child process exited abnormally
My tcl code:
exec egrep -i "^(\\\s+)?(tvf::)?LAYOUT\\\s+PATH" test_file
The test_file contain
LAYOUT PATH "file1"
LAYOUT PATH "file2"
//LAYOUT FILE "file 3"
foo string
tvf::LAYOUT PATH "file4"
tvf::LAYOUT PATH "file5"
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Hello all,
I did some additional investigations and run this command also on 32 bit machine. The command works properly with 32 bit egrep
Result:
LAYOUT PATH "file1"
LAYOUT PATH "file2"
tvf::LAYOUT PATH "file3"
tvf::LAYOUT PATH "file3"
file /bin/egrep */bin/egrep: symbolic link to `grep'*
file /bin/grep */bin/grep: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped*
But when I remove additional backslashes :
exec egrep -i "^(\s+)?(tvf::)?LAYOUT\s+PATH" test_file
The command return error:
child process exited abnormally
The egrep version on 64 bit machine is:
file /bin/egrep */bin/egrep: symbolic link to `grep'*
file /bin/grep */bin/grep: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped*
grep uses its exit status to indicate presence/absence of a match (man page) - if no matches the exit status is 1. Tcl's exec
treats any non-zero exit status as an exceptional situation. You need to catch
the exec call, check the return value from catch and if nonzero examine the $errorCode
variable. A thorough example here: http://wiki.tcl.tk/exec, click "Show Discussion" and scroll down to KBK's example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With