LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-03-2011, 02:12 PM   #1
Dockstar
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Rep: Reputation: Disabled
Running a remote PHP file from an unattended computer


Hi,

I'm a beginner and after vainly trying to find a remedy to a wget problem, I'm now trying solve my problem another way which is to run/call a remote PHP file from an unattended computer.
The idea is that every ten minutes, the unattended machine would call/run w ww.whatever.com/this_one.php

I know how to get the content of a remote file with "wget" (obviously not when it resides on my modem...) but is there something like a "wrun" or similar to start a PHP file on a remote site ?

Thanks

Last edited by Dockstar; 10-03-2011 at 03:24 PM. Reason: correcting typo
 
Old 10-03-2011, 02:33 PM   #2
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,200

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
there are several ways you can do this depending on what kind of access you have
1) you can configure a cron job on the machine to run the script periodically at a set time
2) you can ssh into the machine and run the script
3) you can run the script on a local machine and PUT it onto the remote machine via ftp.
those are just a couple ways of doing this.
 
Old 10-03-2011, 03:23 PM   #3
Dockstar
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
Probably I wasn't clear enough.

The machine will be unattended and the remote PHP script must be run every 5 to 10 minutes so that takes out SSH or running the script manually. So, yes, it is obviously a cron job but what I'm looking for is which command to put in front of http://www.whatever.com/this_one.php in the bash script.

That's why I was asking what would be the "wrun" kind of command.
 
Old 10-03-2011, 04:24 PM   #4
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,200

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
it wold be more like
Code:
php /path/to/this_one.php
or

Code:
wget -O - -q -t 1 http://www.example.com/this_one.php

Last edited by frieza; 10-03-2011 at 04:25 PM.
 
Old 10-04-2011, 09:36 AM   #5
Dockstar
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
Code:
wget -O - -q -t 1 http://www.example.com/this_one.php
Great ! This did it just fine. I thought "wget" would only get the file, not run it too (if it's a script type of file).
I'm now checking how to parameter a cron job and thus may have further questions.

Thanks Frieza.
 
Old 10-04-2011, 06:04 PM   #6
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,200

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
Quote:
Originally Posted by Dockstar View Post
Code:
wget -O - -q -t 1 http://www.example.com/this_one.php
Great ! This did it just fine. I thought "wget" would only get the file, not run it too (if it's a script type of file).
I'm now checking how to parameter a cron job and thus may have further questions.

Thanks Frieza.
to clarify, php files are executed by the web server, so wget is actually retrieving the output of the script after it gets processed by the web server, however the example above does so silently and discards the information instead of saving it to a file.

if you were able to retrieve raw php code with wget that would be a problem for webmasters, now wouldn't it?
 
Old 10-05-2011, 08:43 AM   #7
Dockstar
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by frieza View Post
to clarify, php files are executed by the web server, so wget is actually retrieving the output of the script after it gets processed by the web server, however the example above does so silently and discards the information instead of saving it to a file.
For reasons best known to my remaining four neurons, I thought wget would be more "low-level" (in the good sense) than a web browser but they must both send a HTTP GET request and thus the web server acts the same.

Quote:
Originally Posted by frieza View Post
if you were able to retrieve raw php code with wget that would be a problem for webmasters, now wouldn't it?
Yes, a webserver never sends a raw php (and most other script files for that matter). Guess it would be a problem for everybody but hackers!
Thanks for your clarification.
 
Old 10-05-2011, 01:32 PM   #8
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,200

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
no problem, yes you can grab raw php code with wget by downloading via ftp with wget, but even then you must still provide valid credentials for the ftp server. hope this helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
remote unattended slackware install bartgymnast Slackware 3 08-12-2009 11:23 AM
Unattended remote installation [GOD]Anck Slackware 0 08-18-2008 07:49 AM
Remote encrypted unattended file server nedlud Linux - Newbie 2 06-20-2008 04:22 PM
killing a running script on remote computer? babag Programming 2 04-07-2008 12:18 AM
How do you connect to another computer and use an application running on it remote? zahadumy Linux - Software 8 05-19-2006 05:43 PM


All times are GMT -5. The time now is 03:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration