Hi
Im trying to post data to a url (http://ipaddress/phpscript.php?number=*********&msg=********)
If I use /tool fetch url=“http://ipaddress/phpscript.php?number=*********&msg=********” mode=http
I get action invalid(6)
Is there any other way to do this?
Thanks
This worked for me. The question mark must be escaped with the backslash and the path enclosed in double quotes. All one line.
/tool fetch mode=http address=1.2.3.4 src-path="/phpscript.php\?number=2" dst-path=phpscript.php
You can use script variables in that also. If you have a environment variable called “$number”, then you can use this to send it in the url. All one line.
/tool fetch mode=http address=1.2.3.4 src-path="/phpscript.php\?number=$number" dst-path=phpscript.php
Good deal. If you did not figure out the rest, the result of the request (webpage minus the header) is in /file in the phpscript.php file.
/file
print detail where name=phpscript.php
If you keep the response page short, you can use the contents to determine the result of the request if it is important.
If I add $number to the src-path I get an error - end of line expected- on the “u” after the “?” as marked in red
/tool fetch mode=http address=1.2.3.4 src-path=“/phpscript.php?number=$number” dst-path=phpscript.php
The variable $number must exist, or it will error like that.
:global number 2;
/tool fetch mode=http address=1.2.3.4 src-path="/phpscript.php\?number=$number" dst-path=phpscript.php
I still gives me the same error
Check “/system script environment” and insure that variable name is there. If it is not there, I get the same error. If it is there, it works.
I’m using v5.25 for this test.
I see it works on v5, they must of change something on v6
I see it works on v5, they must of change something on v6
That makes a person wonder if the script is supposed to work and doesn’t with the new version, or wasn’t supposed to work before and has been “fixed”. ??
I have a similar problem with the question mark ? in a script.
ROS v6.39.2
I have this code in a script and it returns an error (status: failed, failure: closing connection: <unknown protocol:) when I execute the script via terminal CLI /system/script run x or simply fails if I run it in winbox in the script.
/tool fetch mode=http keep-result=no url="http://192.168.0.137/gpsgateserver/
gpsgate.aspx/\?longitude=$newlong&latitude=$newlat&speed=0.0&date=$vdate&time=$nctime&username=mtg
ps&IMEI=admin";
The issue appears to be with the …aspx/?..which is the format needed to send to the server.
From the prior posts I added the backslash \ before the ? to escape but the script still fails…aspx/?
NOW if I run the same code directly from the terminal CLI, it runs and is accepted by website for input. Terminal CLI returns: status: finished
/tool fetch mode=http keep-result=no url=“http://192.168.0.137/gpsgate
server/gpsgate.aspx/?longitude=$newlong&latitude=$newlat&speed=0.0&date=$vdate&time=$nctime&username=mt
gps”;
I have tried it with and without the backlash \ escape character before the ? but I get the same failed result
I have also downgraded to 5.26 with no luck either.
Can someone that has experienced this please help solve this problem?