exec() - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

exec()

bpajkbpajk Posts: 156Member
[b][red]This message was edited by bpajk at 2003-10-21 12:12:5[/red][/b][hr]
My program doesn't go pass the exec() statement! How do I tell him to execute and go foward? When I used Dev-Pascal for a compiler it went passed but in Free-pascal it stops at exec().
[CODE]
program test;
uses dos;
begin
swapvectors;
exec('c:windows
otepad.exe','');
swapvectors;
readln
end.
[/CODE]


Comments

  • ManningManning Posts: 1,621Member
    : [b][red]This message was edited by bpajk at 2003-10-21 12:12:5[/red][/b][hr]
    : My program doesn't go pass the exec() statement! How do I tell him to execute and go foward? When I used Dev-Pascal for a compiler it went passed but in Free-pascal it stops at exec().
    : [CODE]
    : program test;
    : uses dos;
    : begin
    : swapvectors;
    : exec('c:windows
    otepad.exe','');
    : swapvectors;
    : readln
    : end.
    : [/CODE]

    What flavour of FPC? If it's the GO32V2 one, you may need to use:

    [code]
    exec(GetEnv('COMSPEC'), '/C c:windows
    otepad.exe');
    [/code]
  • werner02werner02 Posts: 5Member
    : : [b][red]This message was edited by bpajk at 2003-10-21 12:12:5[/red][/b][hr]
    : : My program doesn't go pass the exec() statement! How do I tell him to execute and go foward? When I used Dev-Pascal for a compiler it went passed but in Free-pascal it stops at exec().
    : : [CODE]
    : : program test;
    : : uses dos;
    : : begin
    : : swapvectors;
    : : exec('c:windows
    otepad.exe','');
    : : swapvectors;
    : : readln
    : : end.
    : : [/CODE]

    :
    : What flavour of FPC? If it's the GO32V2 one, you may need to use:
    :
    : [code]
    : exec(GetEnv('COMSPEC'), '/C c:windows
    otepad.exe');
    : [/code]
    :
    :///////////////////////////////////////////////////////////////////
    Try is one:
    : program test;
    : uses dos;
    : begin

    : command := '/c' + 'windows
    otepad.exe' ;
    : swapvectors;
    : exec(getenv('COMSPEC'), command);
    : swapvectors;
    :////////////////////////////////////////////////////////////////////

    May you can help me in closing that program (written in perl)
    Best Regards
    Werner


  • ManningManning Posts: 1,621Member
    : : : [b][red]This message was edited by bpajk at 2003-10-21 12:12:5[/red][/b][hr]
    : : : My program doesn't go pass the exec() statement! How do I tell him to execute and go foward? When I used Dev-Pascal for a compiler it went passed but in Free-pascal it stops at exec().
    : : : [CODE]
    : : : program test;
    : : : uses dos;
    : : : begin
    : : : swapvectors;
    : : : exec('c:windows
    otepad.exe','');
    : : : swapvectors;
    : : : readln
    : : : end.
    : : : [/CODE]
    :
    : :
    : : What flavour of FPC? If it's the GO32V2 one, you may need to use:
    : :
    : : [code]
    : : exec(GetEnv('COMSPEC'), '/C c:windows
    otepad.exe');
    : : [/code]
    : :
    : :///////////////////////////////////////////////////////////////////
    : Try is one:
    : : program test;
    : : uses dos;
    : : begin
    :
    : : command := '/c' + 'windows
    otepad.exe' ;
    : : swapvectors;
    : : exec(getenv('COMSPEC'), command);
    : : swapvectors;
    : :////////////////////////////////////////////////////////////////////
    :
    : May you can help me in closing that program (written in perl)
    : Best Regards
    : Werner


    Was that a suggestion for bpajk to try, or are you asking for help with that code?
  • bpajkbpajk Posts: 156Member
    : : : : [b][red]This message was edited by bpajk at 2003-10-21 12:12:5[/red][/b][hr]
    : : : : My program doesn't go pass the exec() statement! How do I tell him to execute and go foward? When I used Dev-Pascal for a compiler it went passed but in Free-pascal it stops at exec().
    : : : : [CODE]
    : : : : program test;
    : : : : uses dos;
    : : : : begin
    : : : : swapvectors;
    : : : : exec('c:windows
    otepad.exe','');
    : : : : swapvectors;
    : : : : readln
    : : : : end.
    : : : : [/CODE]
    : :
    : : :
    : : : What flavour of FPC? If it's the GO32V2 one, you may need to use:
    : : :
    : : : [code]
    : : : exec(GetEnv('COMSPEC'), '/C c:windows
    otepad.exe');
    : : : [/code]
    : : :
    : : :///////////////////////////////////////////////////////////////////
    : : Try is one:
    : : : program test;
    : : : uses dos;
    : : : begin
    : :
    : : : command := '/c' + 'windows
    otepad.exe' ;
    : : : swapvectors;
    : : : exec(getenv('COMSPEC'), command);
    : : : swapvectors;
    : : :////////////////////////////////////////////////////////////////////
    : :
    : : May you can help me in closing that program (written in perl)
    : : Best Regards
    : : Werner
    :
    :
    : Was that a suggestion for bpajk to try, or are you asking for help with that code?
    :
    It worked! But There is a trick to this:
    If you use: exec('c:windows
    otepad.exe',''); It will not pass the exec() statement until the program is finished, but if you use: exec(GetEnv('COMSPEC'), '/Cc:windows
    otepad.exe'); it will execute the program and go pass. Thanx!


  • Dominik101Dominik101 Posts: 1Member
    Hi Bpajk,

    I have the same problem in FPC, when opening the notepad.
    SwapVectors;
    Exec(GetEnv('COMSPEC'),'/C '+ '>notepad.exe c:active.txt');
    SwapVectors;


    Exec() opens the notepad but the program doesn't go forward until notepad is closed.

    I tried your code:
    exec(GetEnv('COMSPEC'), '/Cc:windows
    otepad.exe');

    but the effect is just the same.
    The programs opens notepad and stops.

    Can you help and tell how you solved the problem?
  • AtexAtex Posts: 268Member
    [code][color=Blue]// Compiler: FPC

    uses windows;

    begin
    [b]winexec('notepad.exe',1);[/b]
    writeln('Test');
    readln;
    end.[/color][/code]
Sign In or Register to comment.