hey guys...

i need some help here...i am trying to run an .exe program from my web page. however, it does not work as it should be. the program should generate some random number and write it to a txt file.

i do not know whether it execute the program or not, but it does not write to the txt file for sure since as i print out the file, it is not updated.

i use code below to execute my program in DOS and it works fine:

C:\Prog~1\02VALKEY.EXE /CC /R991LR1LJ1KSASMAS /T1212;

i think i got confused in the way i pass parameters to my exe program. i have couple of methods below with no luck 🙁

$RegKey = "991LR1LJ1KSASMAS";

$runprogram = "\"http://test.mysite.com/webclick/02VALKEY\" \"/CC /R$RegKey /T1212\"";

OR 

$runprogram = "'02VALKEY.EXE' /CC /R$RegKey /T1212";

OR

$runprogram = "start \"http:\"\"//\"test.mysite.com\"/\"webclick\"/\"02VALKEY.EXE \"/\"CC \"/\"R991LR1LJ1KSASMAS \"/\"T1212\""; 

OR

$runprogram = "start \"/files/02VALKEY.EXE\" /CC \" \"R$RegKey\" \"T1212\""; 

OR

$runprogram = "start '02VALKEY.EXE /CC /R' .$RegKey. ' /T1212;'";

OR

$runprogram = "start \"http:\"\"//\"test.mysite.com/webclick/02VALKEY.EXE\" \"/CC /R991LR1LJ1KSASMAS /T1212;\""; 

OR

$runprogram = "start /D \"/var/www/test/webclick/\" /B 02VALKEY.EXE \"/CC \" \"/R991LR1LJ1KSASMAS  \" \"/T1212;\""; 

exec($runprogram);

can someone help me to make it works? i have looked and searched Manual, this and other forums, but there is no explanation about the 'correct method' to pass parameters.

i will also thankful if someone can point me a link where i can get some kind of tutorial to work with exec() parameters.

one other thing, how can i print error (if there is any) to see whether my code works or not? since i do not know whether there is error or not in my code so far.

thanks in advance for your time and help. really appreciate it.

    Why, oh why, oh why would you use an external program to generate a random number when you could do it in PHP?

      thanks for ur reply...

      well...i know i can easily create another program to generate random number in PHP.

      but the program i'm trying to execute from my web page is part of the application that we have. that program will generate some kind of validation/confirmation for that application. so far we do it by manually, customers call us, give us information, we run the program, n we give them the key.

      we are just trying to make it simple for ourselves by creating this application. So with this application, people can get their needed key through our website after filling out related form.

      hope u understand the situation... 😉

      so...do u mind to share your idea in how i should do the code?? or if you know the links that give more information regarding passing parameters with exec(), i will really appreciate it. Thanks once again though...

        Just put in quotes what you would put on the command line.
        You may need to specify the full path to the program.
        e.g
        'c:\program\02VALKEY.EXE ...'

        HalfaBee

          Originally posted by HalfaBee
          Just put in quotes what you would put on the command line.
          You may need to specify the full path to the program.
          e.g
          'c:\program\02VALKEY.EXE ...'

          HalfaBee

          actualy thats backticks (`, same key as ~)

            thanks for the replies guys...

            unfortunately, i just found out that it has something to do with the Server I am testing the code. I just cannot execute the .exe file from UNIX. So, hopefully, there is nothing wrong with the code that I have right now.

            I'm going to give it a try to run it on Windows server. I'll give you update on how it goes.

            sorry for not giving more detail about my problem.

            Thanks.

              hmmm.... either safe mode is on, or your webserver has no shell (i remember a thread about taht a while back...)....

                No, I think he's trying to execute a .exe file on a Unix machine

                  hmm yah that could be it too. Windoze code wont run on *nox you know!

                    Write a Reply...