redirect exec output to a file 
Author Message
 redirect exec output to a file

Hi,

I have a problem to redirect output from stdout to a file.

I have a shellcommand like "find | grep " and have to redirect the
output from this command into a file.
Concrete the command to execute is:

find $FIND_PATH  -name $FIND_FILE 2>/dev/null | grep -l
$in_search_string 2>/dev/null >> foo.dat

The variables $FIND_PATH, $FIND_FILE, and $in_search_string are
created into the TCL-script.
So I test this with:

Test 1:
set pipe1 [open {|find $FIND_PATH  -name $FIND_FILE 2>/dev/null | grep
-l $in_search_string 2>/dev/null >> foo.dat} w]

Result: The file foo.dat is empty.

Test 2:
puts $return_file_id "[exec  -- find $FIND_PATH  -name $FIND_FILE
2>/dev/null | xargs grep -l $in_search_string 2>/dev/null]"

Result: The file referenced by $return_file_id in not null but the
script breaks with the error:

error reading output from command: interrupted system call
    while executing
"exec  -- find $FIND_PATH  -name $FIND_FILE 2>/dev/null | xargs grep
-l $in_search_string 2>/dev/null"
    ("while" body line 21)
    invoked from within
"while { $act_date_counter } {
    set act_date_counter [get_next_date]

    # This is the path to supply files
    #
    set FIND_PATH $COCO_HOME$..."
    (file "/shared/aix4/user/KarstenPleines/grep_test/find_file2.tcl"
line 362)

Can somebody help me?

Thank you.
Karsten



Sat, 06 Mar 2004 17:33:13 GMT  
 redirect exec output to a file


:I have a shellcommand like "find | grep " and have to redirect the
:output from this command into a file.
:Concrete the command to execute is:
:
:find $FIND_PATH  -name $FIND_FILE 2>/dev/null | grep -l
:$in_search_string 2>/dev/null >> foo.dat

Does this command produce info in foo.dat if you run it from
the command line?

:So I test this with:
:
:Test 1:
:set pipe1 [open {|find $FIND_PATH  -name $FIND_FILE 2>/dev/null | grep
:-l $in_search_string 2>/dev/null >> foo.dat} w]

Hmm - The "[open {|" ... w]" construct says that you plan on writing,
to the pipe1 file descriptor, data to be read by what is inside the open.
But as far as I know, find doesn't read stdin .

I don't _know_ what exactly the rest of your code is doing, so I don't know
whether this is related or not.

Also, have you confirmed that the values of the variables match
your expectation?

:Test 2:
:puts $return_file_id "[exec  -- find $FIND_PATH  -name $FIND_FILE
:2>/dev/null | xargs grep -l $in_search_string 2>/dev/null]"
:
:Result: The file referenced by $return_file_id in not null but the
:script breaks with the error:
:
:error reading output from command: interrupted system call
:    while executing
:"exec  -- find $FIND_PATH  -name $FIND_FILE 2>/dev/null | xargs grep
:-l $in_search_string 2>/dev/null"

I answered this earlier today in the previous thread you started - the
error says that when you tried to run this, your shell commands failed,
and tcl is just letting you know.  Find out what is in those
variables.  For that matter, consider redirecting those stderr descriptors
to a couple of files and see what is happening there.

--
--
"I know of vanishingly few people ... who choose to use ksh." "I'm a minority!"

Even if explicitly stated to the contrary, nothing in this posting



Sun, 07 Mar 2004 01:48:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Redirect Output From exec to text widget

2. Redirecting Output With Exec

3. Redirecting output of a exec'ed application

4. Redirecting Output to files

5. Redirecting to TWO output files

6. Redirecting program output to file

7. how to redirect lpt1 to file-output

8. redirect g77 output into a file under windows xp

9. redirect output of functions to a string or file

10. Redirect file output into variables

11. redirect g77 under DOS 6.22- need output file

12. expect: redirect output into file called `uname -n'.txt

 

 
Powered by phpBB® Forum Software