Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
9 years ago

Running a console executable from a tcl script

Hi there

I am attempting to call a console executable file from a tcl script that should run before every compile. Here are a few iterations that I have tried, but nothing seems to make the tcl script run the executable:

exec ConsoleApp.exe

qexec ConsoleApp.exe

exec BatchToRunConsoleApp.bat

qexec BatchToRunConsoleApp.bat

I am pretty desperate. I made the mistake of assuming that it would not be difficult to run an application from a tcl script and now I cannot seem to do it. Please help.

Regards,

Stu84

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    this works here:

    
    qexec ipconfig
    qexec quartus 
    

    also:

    
    set cmd "qmegawiz -silent OPTIONAL_FILES=NONE ${file_name}"
    post_message "cmd: ${cmd}"
    if {  } {
       post_message -type error "couldn't run $cmd"
    } else {
       post_message -type info 
    }
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Hi,

    this works here:

    
    qexec ipconfig
    qexec quartus 
    

    also:

    
    set cmd "qmegawiz -silent OPTIONAL_FILES=NONE ${file_name}"
    post_message "cmd: ${cmd}"
    if {  } {
       post_message -type error "couldn't run $cmd"
    } else {
       post_message -type info 
    }
    

    --- Quote End ---

    Hi there DUESTERBERG

    I tried your code snippets, and much like mine, they appear to do absolutely nothing. It says in themessage window that the tcl script executed successfully, but no windows consoles execute or appear. Is it poosible that there is something else that I am missing? Thank you for your help.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You'll get the results you describe if your executable doesn't produce any output to STDOUT.

    Your script snippet works fine here.

    Changing your cmd variable to instead use Windows cmd.exe to run the "set" command, you get your environment dumped into Quartus messages.

    
    set cmd "cmd /c set"
    post_message "cmd: ${cmd}"
    if {  } {
        post_message -type error "couldn't run $cmd"
    } else {
        post_message -type info "Command \"$cmd\" successful."
        post_message -type info 
    }
    

    If something basic as this doesn't work for you, not sure what next? Reinstall?

    If this works, then there's a problem with your .exe, or there is a problem executing your .exe from a script like this.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    You'll get the results you describe if your executable doesn't produce any output to STDOUT.

    Your script snippet works fine here.

    Changing your cmd variable to instead use Windows cmd.exe to run the "set" command, you get your environment dumped into Quartus messages.

    
    set cmd "cmd /c set"
    post_message "cmd: ${cmd}"
    if {  } {
        post_message -type error "couldn't run $cmd"
    } else {
        post_message -type info "Command \"$cmd\" successful."
        post_message -type info 
    }
    

    If something basic as this doesn't work for you, not sure what next? Reinstall?

    If this works, then there's a problem with your .exe, or there is a problem executing your .exe from a script like this.

    --- Quote End ---

    Thanks ted.

    I appreciate all the help everyone. After playing around some more, I found my problem:

    The tcl file runs in the project root directory and therefore saves the files there. When I run my app independently, the files are saved in the same directory as the app, hence the reason for my confusion. The code that uses "open" as described above does work, I still seem to be having some issues with qexec and exec, but this does not hinder my progress. Thanks again.