0.sh
0.sh

Reputation: 2762

Error in startup script: child process exited abnormally

am working on my first tcl/tk project but whenever i run the script, it shows me this error

Error in startup script: child process exited abnormally
while executing
"exec which [string tolower $css]"
(procedure "::Ui::scriptSettings" line 16)
invoked from within
"::Ui::scriptSettings $::Ui::scriptSettings"
(procedure "::Ui::Ui" line 15)
invoked from within
"::Ui::Ui"
(file "./init.tcl" line 266)

and it is always on this line

$installationPath insert 0 [exec which [string tolower $css]]

$css is a path that exist on /usr/bin folder

This is the procedure the error is triggered

foreach css $::Ui::CSS {
    set cssScriptLabel [labelframe $settingsCssFrame.cssLabel$i -text $css]
    set optionalArgument [label $cssScriptLabel.optArg$i -text "Optional Arguments"]
    set optArgEntry [entry $cssScriptLabel.optArgEntry$i]

    set outFileLabel [label $cssScriptLabel.outFile$i -text "OutFile/OutDir"]
    set outFileEntry [entry $cssScriptLabel.outFileEntry$i]
    set installationPathLabel [label $cssScriptLabel.installLabel$i -text "Intallation Path"]
    set installationPath [entry $cssScriptLabel.installPath$i]
    $installationPath delete 0 end
    $installationPath insert 0 [exec which [string tolower $css]]
    grid $cssScriptLabel -pady 5 -columnspan 1
    grid $optionalArgument $optArgEntry -sticky news
    grid $outFileLabel $outFileEntry -sticky news
    grid $installationPathLabel $installationPath
    incr i;
}

what i want to do is to replace the text in the entry box with the path name of $css

Upvotes: 0

Views: 2155

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137567

It sounds like the which call is failing to find the program. When it fails to find it, it exits with a non-zero exit code, and Tcl interprets that (correctly!) as a problem, and raises an error. You can handle those errors with catch or try.

try {
    $installationPath insert 0 [exec which [string tolower $css]]
} trap CHILDSTATUS {} {
    # No such program; recover here...
}

With catch instead (which catches all errors, including things like syntax blunders and so on):

if {[catch {
    $installationPath insert 0 [exec which [string tolower $css]]
}]} {
    # No such program; recover here...
}

Upvotes: 2

Related Questions