* "Alex (Oleksandr) Malyushytskyy" <al...@flex-logix.com>
| After issue any command I get child process exited abnormally message.
| example is help.; It looks like command is executed though.
| Under Linux this is not an issue,
Always show a full *TCL* code example (copy/paste from your input
prompt), otherwise it is guesswork on the readers side what you exactly do.
The typical pitfall with 'exec' is the command doing output to stderr,
which is treated as an error by TCL.
E.g. echo to stdout (catch returns 0):
$ tclsh
% catch {exec sh -c {echo this goes to stdout}} msg
0
% set msg
this goes to stdout
Whereas any output to stderr is treated as an error (catch returns 1):
% catch {exec sh -c {echo this goes to stderr >&2}} msg
1
% set msg
this goes to stderr
% set errorCode
NONE
As you can see, the errorCode variable is NONE.
Whereas if an exit code other than 0 occured, it is set to a list
describing the problem:
% catch {exec sh -c {exit 1}} msg
1
% set msg
child process exited abnormally
% set errorCode
CHILDSTATUS 7188 1
(for details see https://www.tcl.tk/man/tcl/TclCmd/tclvars.html#M12)
Thus you probably can tell a 'real' error by the contents of 'errorCode' after exec fails.
HTH
R'
* "Alex (Oleksandr) Malyushytskyy" <al...@flex-logix.com>
| After issue any command I get child process exited abnormally message.
| example is help.; It looks like command is executed though.
| Under Linux this is not an issue,
Always show a full *TCL* code example (copy/paste from your input
prompt), otherwise it is guesswork on the readers side what you exactly do.
The typical pitfall with 'exec' is the command doing output to stderr,
which is treated as an error by TCL.
E.g. echo to stdout (catch returns 0):
$ tclsh
% catch {exec sh -c {echo this goes to stdout}} msg
0
% set msg
this goes to stdout
Whereas any output to stderr is treated as an error (catch returns 1):
% catch {exec sh -c {echo this goes to stderr >&2}} msg
1
% set msg
this goes to stderr
% set errorCode
NONE
As you can see, the errorCode variable is NONE.
Whereas if an exit code other than 0 occured, it is set to a list
describing the problem:
% catch {exec sh -c {exit 1}} msg
1
% set msg
child process exited abnormally
% set errorCode
CHILDSTATUS 7188 1
(for details see https://www.tcl.tk/man/tcl/TclCmd/tclvars.html#M12)
Thus you probably can tell a 'real' error by the contents of 'errorCode' after exec fails.
HTH
R'
On Thursday, September 30, 2021 at 7:57:15 AM UTC-7, Alex (Oleksandr) Malyushytskyy wrote:
Sorry for the noise, I am just starting using tcl,
I am under windows so sh is not available
Here is output with full input for help command.
It looks like there is a problem with child process even though command is executed
Best regards,
Alex
% catch { exec help } msg
1
Then either cmd.exe's 'help' is returning an error code, or the "help"
is output to the stderr channel.
What happens if you change the command to?:
catch {exec help 2> myfile.txt} msg
if you run help in a windows then print out the error level you get 1 as the exit code. so tcl interpretes that as an error ( i.e. not 0 ). This is not a problem withThen either cmd.exe's 'help' is returning an error code, or the "help"
is output to the stderr channel.
What happens if you change the command to?:
catch {exec help 2> myfile.txt} msg% catch {exec help 2> myfile.txt} msg
1
% puts $errorInfo
For more information on a specific command, type HELP command-name
ASSOC Displays or modifies file extension associations.
ATTRIB Displays or changes file attributes.
BREAK Sets or clears extended CTRL+C checking.
BCDEDIT Sets properties in boot database to control boot loading.
CACLS Displays or modifies access control lists (ACLs) of files.
CALL Calls one batch program from another.
CD Displays the name of or changes the current directory.
CHCP Displays or sets the active code page number.
CHDIR Displays the name of or changes the current directory.
CHKDSK Checks a disk and displays a status report.
CHKNTFS Displays or modifies the checking of disk at boot time.
CLS Clears the screen.
CMD Starts a new instance of the Windows command interpreter.
COLOR Sets the default console foreground and background colors.
COMP Compares the contents of two files or sets of files.
COMPACT Displays or alters the compression of files on NTFS partitions. CONVERT Converts FAT volumes to NTFS. You cannot convert the
current drive.
COPY Copies one or more files to another location.
DATE Displays or sets the date.
DEL Deletes one or more files.
DIR Displays a list of files and subdirectories in a directory.
DISKPART Displays or configures Disk Partition properties.
DOSKEY Edits command lines, recalls Windows commands, and
creates macros.
DRIVERQUERY Displays current device driver status and properties.
ECHO Displays messages, or turns command echoing on or off.
ENDLOCAL Ends localization of environment changes in a batch file.
ERASE Deletes one or more files.
EXIT Quits the CMD.EXE program (command interpreter).
FC Compares two files or sets of files, and displays the
differences between them.
FIND Searches for a text string in a file or files.
FINDSTR Searches for strings in files.
FOR Runs a specified command for each file in a set of files.
FORMAT Formats a disk for use with Windows.
FSUTIL Displays or configures the file system properties.
FTYPE Displays or modifies file types used in file extension
associations.
GOTO Directs the Windows command interpreter to a labeled line in
a batch program.
GPRESULT Displays Group Policy information for machine or user.
GRAFTABL Enables Windows to display an extended character set in
graphics mode.
HELP Provides Help information for Windows commands.
ICACLS Display, modify, backup, or restore ACLs for files and
directories.
IF Performs conditional processing in batch programs.
LABEL Creates, changes, or deletes the volume label of a disk.
MD Creates a directory.
MKDIR Creates a directory.
MKLINK Creates Symbolic Links and Hard Links
MODE Configures a system device.
MORE Displays output one screen at a time.
MOVE Moves one or more files from one directory to another
directory.
OPENFILES Displays files opened by remote users for a file share.
PATH Displays or sets a search path for executable files.
PAUSE Suspends processing of a batch file and displays a message.
POPD Restores the previous value of the current directory saved by
PUSHD.
PRINT Prints a text file.
PROMPT Changes the Windows command prompt.
PUSHD Saves the current directory then changes it.
RD Removes a directory.
RECOVER Recovers readable information from a bad or defective disk.
REM Records comments (remarks) in batch files or CONFIG.SYS.
REN Renames a file or files.
RENAME Renames a file or files.
REPLACE Replaces files.
RMDIR Removes a directory.
ROBOCOPY Advanced utility to copy files and directory trees
SET Displays, sets, or removes Windows environment variables.
SETLOCAL Begins localization of environment changes in a batch file.
SC Displays or configures services (background processes).
SCHTASKS Schedules commands and programs to run on a computer.
SHIFT Shifts the position of replaceable parameters in batch files.
SHUTDOWN Allows proper local or remote shutdown of machine.
SORT Sorts input.
START Starts a separate window to run a specified program or command.
SUBST Associates a path with a drive letter.
SYSTEMINFO Displays machine specific properties and configuration.
TASKLIST Displays all currently running tasks including services.
TASKKILL Kill or stop a running process or application.
TIME Displays or sets the system time.
TITLE Sets the window title for a CMD.EXE session.
TREE Graphically displays the directory structure of a drive or
path.
TYPE Displays the contents of a text file.
VER Displays the Windows version.
VERIFY Tells Windows whether to verify that your files are written
correctly to a disk.
VOL Displays a disk volume label and serial number.
XCOPY Copies files and directory trees.
WMIC Displays WMI information inside interactive command shell.
For more information on tools see the command-line reference in the online help.
child process exited abnormally
while executing
"exec help 2> myfile.txt"
% set errorCode
CHILDSTATUS 20112 1
%
help.....
echo Exit Code is %errorlevel%Exit Code is 1
On Thursday, September 30, 2021 at 3:26:54 PM UTC-5, al...@flex-logix.com wrote:
Then either cmd.exe's 'help' is returning an error code, or the "help"
is output to the stderr channel.
What happens if you change the command to?:
catch {exec help 2> myfile.txt} msg% catch {exec help 2> myfile.txt} msg
1
% puts $errorInfo
For more information on a specific command, type HELP command-name
ASSOC Displays or modifies file extension associations.
ATTRIB Displays or changes file attributes.
BREAK Sets or clears extended CTRL+C checking.
BCDEDIT Sets properties in boot database to control boot loading.
CACLS Displays or modifies access control lists (ACLs) of files.
CALL Calls one batch program from another.
CD Displays the name of or changes the current directory.
CHCP Displays or sets the active code page number.
CHDIR Displays the name of or changes the current directory.
CHKDSK Checks a disk and displays a status report.
CHKNTFS Displays or modifies the checking of disk at boot time.
CLS Clears the screen.
CMD Starts a new instance of the Windows command interpreter.
COLOR Sets the default console foreground and background colors.
COMP Compares the contents of two files or sets of files.
COMPACT Displays or alters the compression of files on NTFS partitions. CONVERT Converts FAT volumes to NTFS. You cannot convert the
current drive.
COPY Copies one or more files to another location.
DATE Displays or sets the date.
DEL Deletes one or more files.
DIR Displays a list of files and subdirectories in a directory.
DISKPART Displays or configures Disk Partition properties.
DOSKEY Edits command lines, recalls Windows commands, and
creates macros.
DRIVERQUERY Displays current device driver status and properties.
ECHO Displays messages, or turns command echoing on or off.
ENDLOCAL Ends localization of environment changes in a batch file.
ERASE Deletes one or more files.
EXIT Quits the CMD.EXE program (command interpreter).
FC Compares two files or sets of files, and displays the
differences between them.
FIND Searches for a text string in a file or files.
FINDSTR Searches for strings in files.
FOR Runs a specified command for each file in a set of files.
FORMAT Formats a disk for use with Windows.
FSUTIL Displays or configures the file system properties.
FTYPE Displays or modifies file types used in file extension
associations.
GOTO Directs the Windows command interpreter to a labeled line in
a batch program.
GPRESULT Displays Group Policy information for machine or user.
GRAFTABL Enables Windows to display an extended character set in
graphics mode.
HELP Provides Help information for Windows commands.
ICACLS Display, modify, backup, or restore ACLs for files and
directories.
IF Performs conditional processing in batch programs.
LABEL Creates, changes, or deletes the volume label of a disk.
MD Creates a directory.
MKDIR Creates a directory.
MKLINK Creates Symbolic Links and Hard Links
MODE Configures a system device.
MORE Displays output one screen at a time.
MOVE Moves one or more files from one directory to another
directory.
OPENFILES Displays files opened by remote users for a file share.
PATH Displays or sets a search path for executable files.
PAUSE Suspends processing of a batch file and displays a message.
POPD Restores the previous value of the current directory saved by
PUSHD.
PRINT Prints a text file.
PROMPT Changes the Windows command prompt.
PUSHD Saves the current directory then changes it.
RD Removes a directory.
RECOVER Recovers readable information from a bad or defective disk.
REM Records comments (remarks) in batch files or CONFIG.SYS.
REN Renames a file or files.
RENAME Renames a file or files.
REPLACE Replaces files.
RMDIR Removes a directory.
ROBOCOPY Advanced utility to copy files and directory trees
SET Displays, sets, or removes Windows environment variables.
SETLOCAL Begins localization of environment changes in a batch file.
SC Displays or configures services (background processes).
SCHTASKS Schedules commands and programs to run on a computer.
SHIFT Shifts the position of replaceable parameters in batch files. SHUTDOWN Allows proper local or remote shutdown of machine.
SORT Sorts input.
START Starts a separate window to run a specified program or command.
SUBST Associates a path with a drive letter.
SYSTEMINFO Displays machine specific properties and configuration.
TASKLIST Displays all currently running tasks including services.
TASKKILL Kill or stop a running process or application.
TIME Displays or sets the system time.
TITLE Sets the window title for a CMD.EXE session.
TREE Graphically displays the directory structure of a drive or
path.
TYPE Displays the contents of a text file.
VER Displays the Windows version.
VERIFY Tells Windows whether to verify that your files are written correctly to a disk.
VOL Displays a disk volume label and serial number.
XCOPY Copies files and directory trees.
WMIC Displays WMI information inside interactive command shell.
For more information on tools see the command-line reference in the online help.if you run help in a windows then print out the error level you get 1 as the exit code. so tcl interpretes that as an error ( i.e. not 0 ). This is not a problem with
child process exited abnormally
while executing
"exec help 2> myfile.txt"
% set errorCode
CHILDSTATUS 20112 1
%
tcl .
help.....
echo Exit Code is %errorlevel%Exit Code is 1
* Bezoar <cwj...@gmail.com>
| if you run help in a windows then print out the error level you get 1
| as the exit code. so tcl interpretes that as an error ( i.e. not 0 ).
| This is not a problem with tcl .
| c:\> help
| .....
| c:\> echo Exit Code is %errorlevel%
| Exit Code is 1
| c:\>
LOL, it's even worse:
C:\Users\ralf>help foobar
Zu diesem Befehl steht kein Hilfethema zur Verfügung.
Versuchen Sie es mit "foobar /?".
(i.e. "no help available for foobar")
C:\Users\ralf>echo %errorlevel%
0
So 'help' reverses the usual scheme of "exit-code 0 is success, anything else is errorcode". Microsoft again...
R'
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 73:44:31 |
Calls: | 6,489 |
Calls today: | 2 |
Files: | 12,096 |
Messages: | 5,275,926 |