How to run external file from Slicer Scripted Module Example?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to run external file from Slicer Scripted Module Example?

madanrao
Hello all,

I am trying to run a simple hello.cpp program from slicer3:

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

void main(){
FILE *fp1;
fp1=fopen("hello.txt","w");

fprintf(fp1,"Hello how are you?\n");
fclose(fp1);
}

hello.exe file is in C:\vmtktest\plugin folder.

I changed the following code in ScriptedModuleExampleGUI.tcl

proc ScriptedModuleExampleApply {this} {

  exec c:/vmtktest/plugin/hello
}

When I click the apply button in Scripted Module Example module there is no error but the hello.txt is not printed.

I can run successfully:

exec c:/windows/system32/cmd.exe /c start /min c:/windows/system32/notepad /p myfile.txt

What is the correct tcl code to print hello.txt?

AM Mohan Rao

_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: How to run external file from Slicer Scripted Module Example?

pieper
Administrator
Hi Mohan -

It looks like 'hello.txt' will be written in the slicer current working
directory - did you look there?

Maybe try changing the argument to fopen to be 'c:/hello.txt' ?

-Steve

On F/18/10 10:36 AM, Madan Rao wrote:

> Hello all,
>
> I am trying to run a simple hello.cpp program from slicer3:
>
> #include <string.h>
> #include <stdlib.h>
> #include <stdio.h>
>
> void main(){
> FILE *fp1;
> fp1=fopen("hello.txt","w");
>
> fprintf(fp1,"Hello how are you?\n");
> fclose(fp1);
> }
>
> hello.exe file is in C:\vmtktest\plugin folder.
>
> I changed the following code in ScriptedModuleExampleGUI.tcl
>
> proc ScriptedModuleExampleApply {this} {
>
>    exec c:/vmtktest/plugin/hello
> }
>
> When I click the apply button in Scripted Module Example module there is
> no error but the hello.txt is not printed.
>
> I can run successfully:
>
> exec c:/windows/system32/cmd.exe /c start /min
> c:/windows/system32/notepad /p myfile.txt
>
> What is the correct tcl code to print hello.txt?
>
> AM Mohan Rao
>
>
>
> _______________________________________________
> slicer-users mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
> To unsubscribe: send email to [hidden email] with unsubscribe as the subject
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: How to run external file from Slicer Scripted Module Example?

madanrao
Hello Steve,

Thanks. Found it at slicer root.

AM Mohan Rao

On Fri, Feb 19, 2010 at 12:00 AM, Steve Pieper <[hidden email]> wrote:
Hi Mohan -

It looks like 'hello.txt' will be written in the slicer current working directory - did you look there?

Maybe try changing the argument to fopen to be 'c:/hello.txt' ?

-Steve


On F/18/10 10:36 AM, Madan Rao wrote:
Hello all,

I am trying to run a simple hello.cpp program from slicer3:

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

void main(){
FILE *fp1;
fp1=fopen("hello.txt","w");

fprintf(fp1,"Hello how are you?\n");
fclose(fp1);
}

hello.exe file is in C:\vmtktest\plugin folder.

I changed the following code in ScriptedModuleExampleGUI.tcl

proc ScriptedModuleExampleApply {this} {

  exec c:/vmtktest/plugin/hello
}

When I click the apply button in Scripted Module Example module there is
no error but the hello.txt is not printed.

I can run successfully:

exec c:/windows/system32/cmd.exe /c start /min
c:/windows/system32/notepad /p myfile.txt

What is the correct tcl code to print hello.txt?

AM Mohan Rao



_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject