Re: output error messages



On Jun 2, 5:15 pm, Dave <hende...@xxxxxxxxx> wrote:
Gang,

     I'm still working on the same script from the post yesterday
(which had its previous problem resolved this morning).  I'm issuing a
'mv' command via spawn but the script isn't throwing any errors,
however the file thats attempted to be moved is not moving either.
I'm sure there is an error message being displayed by the 'mv'
command, but I don't know how to access the message.  I've tried using
'catch' and can display an error code, but not the message (as shown
below).  Any help on being able to print the error message so I can
see (whether to screen or file) would greatly be appreciated.

catch { eval spawn -noecho $syntax } curr_result
send_user "error is: $curr_result\n";

NOTE: $syntax contains the command to execute and is passed into the
script via a parameter value.  At present, I'm just trying something
simple like "mv a.txt b.txt" where a.txt doesn't exist so I can print
out the error message.

From what you wrote here and in the other thread, I don't see a good
reason to use Expect. Are there other considerations that would change
this impression ? Do you need to control interactive things like
telnet, ssh, ftp, rlogin ?

If not, just do it with vanilla tclsh.
Then you'll see that

catch {exec sh -c $syntax} curr_result

does retrieve the error.
Alternatively, you can tell Tcl to let the stderr of the commands flow
to the console unimpeded, and just get the binary success information:

set nok [catch {exec sh -c $syntax 2>@ stderr}]

-Alex

.



Relevant Pages

  • Re: output error messages
    ... I'm sure there is an error message being displayed by the 'mv' ... command, but I don't know how to access the message. ... script via a parameter value. ... Currently I'm using the 'spawn' syntax to launch commands, ...
    (comp.lang.tcl)
  • Re: output error messages
    ... I'm sure there is an error message being displayed by the 'mv' ... command, but I don't know how to access the message. ... script via a parameter value. ... Currently I'm using the 'spawn' syntax to launch commands, ...
    (comp.lang.tcl)
  • output error messages
    ... I'm still working on the same script from the post yesterday ... I'm sure there is an error message being displayed by the 'mv' ... command, but I don't know how to access the message. ... 'catch' and can display an error code, but not the message (as shown ...
    (comp.lang.tcl)
  • Re: JETCOMP.exe utility switch to path to database to compact
    ... I ran the command line script many times. ... error message something about can't find the internal program. ... operable program or batch file. ...
    (microsoft.public.scripting.vbscript)
  • Re: Getops wildcard expansion
    ... on the command line of a script. ...   With option number 1 you can use the following script: ... The "" around wildcard filename and the removal from OPTARG caused the ...
    (comp.unix.shell)