0

Below is my batchfile script. When i setup cronjob via Taskscheduler and run the bat file, cmd line opens with the below batchfile script. But at the same time below specified url is opens in browser and getting the output on browser.

cmd /k start "D:\xampp\php\php.exe" "http://localhost/server/php/ping1.php" 

But I need output on the commandline instead of opening in browser.How can i achieve this? Any help would be greatly appreciated.

File should execute via cmd line only . But it is executing via browser.

user3408779
  • 981
  • 2
  • 19
  • 43
  • 2
    I am not 100% sure of your question. Do you want the output of the `php` file in the console or the output of the `html` created when the command is run? can you give some examples of the expected output by editing your question? So show example of what the html output is as well as the content of the `.php` – Gerhard Apr 21 '17 at 06:25
  • File should execute via cmd line only . But it is executing via browser. – user3408779 Apr 21 '17 at 06:27
  • 2
    still unclear, what file? show the content of the php file as well as your expected output you require. – Gerhard Apr 21 '17 at 06:30
  • for example the file name is insert.php . when i run the file the insert query should execute and insert in the related table via cmd line. Not via browser. The file should not open/run/execute via browser. It should execute via command line only – user3408779 Apr 21 '17 at 06:37
  • 1
    Maybe something like [this](http://stackoverflow.com/a/23512143/2861476) is what you need. – MC ND Apr 21 '17 at 06:39
  • What file?? The PHP file? – Gerhard Apr 21 '17 at 06:42
  • yes php file only – user3408779 Apr 21 '17 at 06:49
  • just the content of the php on command line? You need to help me help you. please edit the question and add the expected output and content of the PHP file. – Gerhard Apr 21 '17 at 06:58
  • or do you want the content of the php file to execute on command line? please show the content of the php file. – Gerhard Apr 21 '17 at 07:13

2 Answers2

1

You will need some 3rd party utility such as wget or curl. Then you can use

curl.exe -k --url https://localhost/server/php/ping1.php
vitsoft
  • 5,515
  • 1
  • 18
  • 31
0

I'm going to take a wild guess and say that your problem is with the Start command.

Either get rid of it completely:

cmd /k ""D:\xampp\php\php.exe" "http://localhost/server/php/ping1.php""

Or use it with it's correct structure (title):

cmd /k "start "running php" "D:\xampp\php\php.exe" "http://localhost/server/php/ping1.php""
Compo
  • 36,585
  • 5
  • 27
  • 39