All I want is to start a bunch of background processes from the shell. That's all.
Here's what I have in a batch file called start_servers:
@ECHO OFF
call setenv
START "" /B xampp\apache_start.bat
START "" /B xampp\mysql_start.bat
START "" /B php start_daemon.php
echo Server started
when I run this by double clicking the batch file, it all works fine. I get the output of all 3 processes in 1 window. However, if I start the shell in the same directory, type in 'start_servers.bat' and hit enter, it runs apache_start and mysql_start just fine, but the php script 'start_daemon' seemingly doesnt run, but I get 'Server started' outputted.
The weirdest thing though is If I hit enter once more, then php start_daemon.php runs! It's as if 'php start_daemon.php' is being typed on my keyboard, but it's invisible to me. When I hit enter, it appears like so:
[cwd]> start_servers.bat
...
[cwd]>Websocket Server started
Listening on: 0.0.0.0:9000
Master socket: Resource id #7
Notice the part '[cwd]>Server started' like I entered it as a command.
I've spent a whole day trying to work this out, It's driving me crazy!!!!!
Please please please help.
EDIT:
I've just been trying some other things and I'm still getting the same damn result. If I reduce the .bat down to 'START "" /B php start_daemon.php' or if I simply type it into the commandline, I get the same result. First return, nothing. Second return, it runs.
I've also tried the following:
START "" /B node test.js
result:
C:\Users\hedge\Projects\PHPStorm\gpstudios>this is a test
what I expect:
this is a test
C:\Users\hedge\Projects\PHPStorm\gpstudios>
Also:
START "" /B python2 test.py
result:
C:\Users\hedge\Projects\PHPStorm\gpstudios>this is a test
And finally:
START "" /B python3 test.py
result:
C:\Users\hedge\Projects\PHPStorm\gpstudios> [nothing, I hit return]
C:\Users\hedge\Projects\PHPStorm\gpstudios> [nothing again, I hit return]
C:\Users\hedge\Projects\PHPStorm\gpstudios>this is a test
What on earth is going on? They all output the result to the line where I type my commands, which i suppose makes sense as the terminal is not waiting for the START call to finish before handing control back to me, however, PHP scripts require I hit return once more, and a Python3 script requires 2 returns! This is not at all intuitive. Again, I plead for help. This is killing me.
EDIT 2:
If I run 'START "" /B /WAIT php start_daemon.php' or 'php start_daemon.php' then obviously, the script runs immediately and as expected, but it then freezes the shell and requires I start a new one in order to input any further commands. I plan on running more than one background processes via node or php, but as it is I can only run one in a single CMD terminal.
I'm just trying to rephrase the problem a little in hope of getting some replies, if that helps...