944,066 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 15033
  • PHP RSS
Oct 22nd, 2009
0

How to execute php script without browser?

Expand Post »
Hi to all experts in the forum.
I know scripts can be executed through the command prompt,but what are other ways to execute it, if the file is on remote server.
Please specify if any clarification is needed.
Similar Threads
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Oct 22nd, 2009
0
Re: How to execute php script without browser?
Several ways to run a PHP script outside browser:
CLI (Command Line Interface)
Call your script like #php /path/to/your/script.php from terminal/CMD
Telnet/SSH (Same as above)
Crond
On *NIX systems there is something called CROND which allows you to execute scripts according to a schedule E.G. every hour, every day, the first monday of each month etc.
Look up CROND tutorials on Google and use the above CLI example as your script
#!
Not sure if this works but you may be able to run it by adding the line
#! /etc/php to the first line of your script then run it by double clicking (Only on Unix/Linux)
If I have not answered your question just say but those are the main ways of running scripts outside browser
Reputation Points: 26
Solved Threads: 31
Posting Whiz
samarudge is offline Offline
354 posts
since May 2008
Oct 22nd, 2009
0
Re: How to execute php script without browser?
thanks.good post.I am aware about setting up the cron but here we should not do that.
I did a script to run as a process and transferred it to some server using ftp, so we don't have remote access to that server.
So no double clicking the file, that way, though it seem to be a good option (thanks for it, i will like it to give a try sometime later,i just got to see it).
Hope i cleared the scenario , if not please ask, i will need to clarify.
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Oct 22nd, 2009
0
Re: How to execute php script without browser?
If you only have basic FTP access I don't think its possible, some admin panels will let you do it (if you have one) but other than that no ideas so sorry =(
Reputation Points: 26
Solved Threads: 31
Posting Whiz
samarudge is offline Offline
354 posts
since May 2008
Oct 22nd, 2009
0
Re: How to execute php script without browser?
thanks, it's fine.I also feel now that, it must not be any way except using some external tools designed to execute the script remotely on that specific servers
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Oct 22nd, 2009
0
Re: How to execute php script without browser?
There is another way if you have ssh access to the server and a local Linux machine. From the local Linux machine use rsh to invoke the script on the server. There are several tricks that can be employed here that would allow you to automate access to your server without requiring username and password, a search for Private/Public Key and known_hosts should do the trick. Just remember to set permissions on the script so that it is executable and as mentioned above ensure that the first line of the script identifies the PHP CLI runtime.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
moorlie is offline Offline
1 posts
since Oct 2009
Oct 25th, 2009
0
Re: How to execute php script without browser?
hey thanks moorlie, that's one nice too.by this time got so many things about PHP CLI.closing the thread
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Jan 21st, 2011
0
Re: How to execute php script without browser?
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: application/octet-stream");
// change, added quotes to allow spaces in filenames, by Rajkumar Singh
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile("$filename");
exit();
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jan.cajthaml is offline Offline
1 posts
since Jan 2011

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP mysql
Next Thread in PHP Forum Timeline: ASP - PHP - JSP ... which is better?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC