Launching php script through comman line - keeping terminal window open after execution
Posted
by
somethis
on Ask Ubuntu
See other posts from Ask Ubuntu
or by somethis
Published on 2013-03-29T10:15:11Z
Indexed on
2013/06/30
10:28 UTC
Read the original article
Hit count: 300
Oh, my girlfriend really likes it when I launch php scripts! There's something special about them, she says ...
Thus, I coded this script to run throught the CLI (Command Line Interface) - so it's running locally, not on a web server.
It launches just fine through right click > open > run in terminal but closes right after execution. **Is there a way to keep the terminal window open?
Of course I can launch it through a terminal window - which would stay open - but I'm looking for a one click action. With bash scripts I use $SHELL
but that didn't work (see code below).
So far, the only thing I came up with is sleep(10);
which gives me 10 seconds for my girl to check the output. I'd rather close the terminal window manually, though.
#!/usr/bin/php -q
<?php
echo "Hello World \n";
# wait before closing terminal window
sleep(10);
# the following line doesn't work
$SHELL;
?>
(PHP 5.4.6-1ubuntu1.2 (cli) (built: Mar 11 2013 14:57:54) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies )
© Ask Ubuntu or respective owner