Community discussions

MikroTik App
 
User avatar
tplecko
Member Candidate
Member Candidate
Topic Author
Posts: 120
Joined: Mon Jun 11, 2007 12:18 pm
Location: Croatia
Contact:

Fetching a php file

Sat Oct 09, 2010 6:23 pm

Is there any reason why any of this would result in endless waiting (status changes to 'downloading' and then it just counts time)

tool fetch url="http://www.some.com/something.hr/mt/upd ... yyyy-mm-dd hh:mm" mode=http


this results the same
tool fetch address="www.some.com" src-path="/something.hr/mt/update.php?u=1&p=b9fedbb1b5952500c58208097c808db1&d=7&i=0.0.0.0&s=x86&v=ver&t=yyyy-mm-dd hh:mm" mode=http


And allso, is there a way to read the file?
The php file enters the information into SQL and if successful, returnd character 1 (or 0 if unsuccessful)
so i can do something if returned 0 or 1?


thanks
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Fetching a php file

Sat Oct 09, 2010 10:41 pm

I've seen cases where if the return data is empty /tool fetch would hang and continue "downloading" for a long time. Just ensure (maybe through a packet capture), that data is in fact being returned from the server.

To read the data returned by the server, set dst-path=<somefile>. If the return data is < 4095 bytes, you can read it inside RouterOS by using:
/file get <somefile> contents
 
User avatar
tplecko
Member Candidate
Member Candidate
Topic Author
Posts: 120
Joined: Mon Jun 11, 2007 12:18 pm
Location: Croatia
Contact:

Re: Fetching a php file

Mon Oct 11, 2010 11:37 am

It used to work but i accidentaly deleted the script 8-(
If i enter the URL in a browser, i get exactly what i need.

when i break the download (after waiting for a long time) i get the error 'no such item'


could you try fetching this:
/tool fetch address="www.giganet.hr" src-path="/avatars/tp-avatar.png" mode=http dst-path="tp-avatar.png"
I get a 404 error

and since i will delete the record in sql, try this too:
/tool fetch address="www.giganet.hr" src-path="/giganet.hr/mt/update.php?u=1&p=b9fedbb1b5952500c58208097c808db1&d=7&i=w.x.y.z&s=x86&v=ver&t=yyyy-mm-dd hh:mm" mode=http dst-path="phpresult"
this hangs and when interrupted, 'no such item' error is returned
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7053
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Fetching a php file

Mon Oct 11, 2010 11:39 am

In console ? is a special character that prints help.

Put \ before ?
 
User avatar
tplecko
Member Candidate
Member Candidate
Topic Author
Posts: 120
Joined: Mon Jun 11, 2007 12:18 pm
Location: Croatia
Contact:

Re: Fetching a php file

Mon Oct 11, 2010 11:45 am

Same thing happens
(in console it no longe prints commands, but from script, the same)
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7053
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Fetching a php file

Mon Oct 11, 2010 12:23 pm

Works fine form console and from script
[admin@dzeltenais_burkaans] /system script> print from=php
Flags: I - invalid 
 0   name="php" owner="admin" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive 
     last-started=oct/11/2010 12:20:56 run-count=1 
     source=/tool fetch address="www.giganet.hr" src-path="/giganet.hr/mt/update.php\?u=1&p=b9fedbb1b59
       52500c58208097c808db1&d=7&i=w.x.y.z&s=x86&v=ver&t=yyyy-mm-dd hh:mm" mode=http dst-
       path="phpresult" 
[admin@dzeltenais_burkaans] /system script> run 0
      status: downloading
  downloaded: 0KiB
    duration: 1s
 
User avatar
tplecko
Member Candidate
Member Candidate
Topic Author
Posts: 120
Joined: Mon Jun 11, 2007 12:18 pm
Location: Croatia
Contact:

Re: Fetching a php file

Mon Oct 11, 2010 1:34 pm

Wich version of ROS?

I now copypasted the code you wrote and the same thing. hangs and duration just goes on and on...
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Fetching a php file

Mon Oct 11, 2010 8:29 pm

If I use a browser, I get a 404 error
Not Found

The requested URL /something.hr/mt/update.php was not found on this server.
Apache/2.2.3 (Red Hat) Server at http://www.some.com Port 80
ADD: If you can, please put a simple index.html file in the /avatars directory with the tp-avatar.png. I can get your main page index.html file.
 
User avatar
tplecko
Member Candidate
Member Candidate
Topic Author
Posts: 120
Joined: Mon Jun 11, 2007 12:18 pm
Location: Croatia
Contact:

Re: Fetching a php file

Tue Oct 12, 2010 11:48 am

If I use a browser, I get a 404 error
Not Found

The requested URL /something.hr/mt/update.php was not found on this server.
Apache/2.2.3 (Red Hat) Server at http://www.some.com Port 80
ADD: If you can, please put a simple index.html file in the /avatars directory with the tp-avatar.png. I can get your main page index.html file.
/tool fetch address="www.giganet.hr" src-path="/avatars/tp-avatar.png" mode=http dst-path="tp-avatar.png"
I get a 404 error

/tool fetch address="www.giganet.hr" src-path="/giganet.hr/mt/update.php?u=1&p=b9fedbb1b5952500c58208097c808db1&d=7&i=w.x.y.z&s=x86&v=ver&t=yyyy-mm-dd hh:mm" mode=http dst-path="phpresult"
this hangs and when interrupted, 'no such item' error is returned
Here are the files
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Fetching a php file

Tue Oct 12, 2010 1:12 pm

I am also getting a 404 error still. I can get the image with a browser, so it must be with the fetch routine. I suggest contacting support@mikrotik.com and see what they say.

I can get the http://www.giganet.hr/index.html doc with fetch. Just not anything in the avatars directory.
<html><head><META HTTP-EQUIV="refresh" CONTENT="0;URL=/cgi-
            sys/defaultwebpage.cgi"></head><body></body></html>
I just tried a php file fetch from my site and it downloaded the output of the php file, not the actual file.

ADD: You might want to check your file and directory permissions on the /avatars/ directory and see if anything is different from your main directory also.

Who is online

Users browsing this forum: No registered users and 20 guests