|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi all,
I am not sure if this is the best newsgroup for my question, so feel free to redirect me. I am trying to manipulate my ADSL modem via its web interface in a shell script. Basically, I need to disable and reactive a certain setting, something called ZIPB mode. I am assigned a dynamic IP by my ISP, and when this changes, I need to reactivate ZIPB on the modem manually (an unfortunate limitation on the manufacturer's part). The HTML form looks like this: # <i>disabled.</i> # <FORM method="post" ACTION="/configuration/zipb.html/enable"> # <INPUT type="hidden" name="EmWeb_ns:vim: 4.ImZipbAgent:enabled" value="true"> # <INPUT type="hidden" name="EmWeb_ns:vim:3" value="/ configuration/zipb.html"> # <INPUT type="submit" value="Enable"> # </FORM> So, I try something like this in my shell script: #!/usr/local/bin/bash brackets () { sed -e ' s/</</g s/>/>/g s,/,%2f,g s/?/%3f/g s/:/%3a/g s/@/%40/g s/&/%26/g s/=/%3d/g s/+/%2b/g s/\$/%24/g s/,/%2c/g s/ /%20/g ' } input1=$(echo "EmWeb_ns:vim:4.ImZipbAgent:enabled"|brackets)"="$ (echo "true"|brackets) input2=$(echo "EmWeb_ns:vim:3"|brackets)"="$(echo "/configuration/ zipb.html"|brackets) input3="Enable" curl -d '"'$input1"&"$input2"&"$input3'"' http://$user:$pass@copperjet/configuration/zipb.html/enable >2&1> /dev/ null but all I get is a rather unful reply: curl: (52) Empty reply from server Can anyone suggest ways of debugging this and/or easier ways to go about this? On a related note, I see that there is a book called from No Starch called "Webbots, Spiders, and Screen Scrapers: A Guide to Developing Internet Agents with PHP/CURL" which looks like it covers these techniques, but a) I am not to keen on buying a book on a topic which I don't plan to pursue further than this simple task, and b) I am likewise not so keen on having to learn PHP just to enable me to do this. Thanks for any ideas, -- Colin |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Hi,
I'm using bash for that. My script is below. I don't remember about it because it don't give me troubles. The program "ngrep" is very useful to see communication. As root: /usr/bin/ngrep -W byline -d eth0 -l -p -P ^ Can be redirected to a file if needed. The password is in base64. Just adapt the script or see how it works. Important: it is for http, not https. A good start point is you make what you do manually with ngrep writing to a file. After see the streams between devices you can adapt the script. ----- exec 3<>/dev/tcp/10.0.0.15/2345||return case $1 in IP) echo -e "\ GET /summary.htm HTTP/1.1\r Authorization: Basic OIUojLjloiujljloiUohuiuhihgi=\r Cache-Control: no-cache\r Connection: Close\r \r " >&3 /usr/bin/tr \< \\n <&3|/bin/grep 'FONT color=#008800>'|\ /bin/grep \\.|/bin/cut -d \> -f 2 ;; RST) echo -en "\nModem Reset: `/bin/date`" >&2 echo -en "\ POST /reboot.cgi HTTP/1.1\r Connection: Close\r Authorization: Basic OIUojLjloiujljloiUohuiuhihgi=\r Content-Length: 14\r \r submit1=Reboot">&3 #while read -t 3;do echo "$REPLY" >&2;done <&3 esac exec 3<&- Colin Brace wrote: > Hi all, > > I am not sure if this is the best newsgroup for my question, so feel > free to redirect me. > > I am trying to manipulate my ADSL modem via its web interface in a > shell script. Basically, I need to disable and reactive a certain > setting, something called ZIPB mode. I am assigned a dynamic IP by my > ISP, and when this changes, I need to reactivate ZIPB on the modem > manually (an unfortunate limitation on the manufacturer's part). > > The HTML form looks like this: > > # <i>disabled.</i> > # <FORM method="post" ACTION="/configuration/zipb.html/enable"> > # <INPUT type="hidden" name="EmWeb_ns:vim: > 4.ImZipbAgent:enabled" value="true"> > # <INPUT type="hidden" name="EmWeb_ns:vim:3" value="/ > configuration/zipb.html"> > # <INPUT type="submit" value="Enable"> > # </FORM> > > So, I try something like this in my shell script: > > #!/usr/local/bin/bash > > brackets () { > sed -e ' > s/</</g > s/>/>/g > s,/,%2f,g > s/?/%3f/g > s/:/%3a/g > s/@/%40/g > s/&/%26/g > s/=/%3d/g > s/+/%2b/g > s/\$/%24/g > s/,/%2c/g > s/ /%20/g > ' > } > > input1=$(echo "EmWeb_ns:vim:4.ImZipbAgent:enabled"|brackets)"="$ (echo > "true"|brackets) > input2=$(echo "EmWeb_ns:vim:3"|brackets)"="$(echo "/configuration/ > zipb.html"|brackets) > input3="Enable" > > curl -d '"'$input1"&"$input2"&"$input3'"' > http://$user:$pass@copperjet/configuration/zipb.html/enable >2&1> /dev/ > null > > but all I get is a rather unful reply: > > curl: (52) Empty reply from server > > Can anyone suggest ways of debugging this and/or easier ways to go > about this? > > On a related note, I see that there is a book called from No Starch > called "Webbots, Spiders, and Screen Scrapers: A Guide to Developing > Internet Agents with PHP/CURL" which looks like it covers these > techniques, but > > a) I am not to keen on buying a book on a topic which I don't plan to > pursue further than this simple task, and > > b) I am likewise not so keen on having to learn PHP just to enable me > to do this. > > Thanks for any ideas, > -- Colin |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On May 3, 3:35pm, mop2 <mop2bky4mz5tyjwa8ersp7hrg5u...@gmail.com>
wrote: > I'm using bash for that. > My script is below. Hi, By coincidence, I found another of doing this on this web page: https://secure.dd-wrt.com/phpBB2/vie...c0d0cf6709bd72 It uses the telnet interface of the ADSL modem I have, a Copperjet from Allied Data. I adapted it in my script like this: in /etc/hosts: 172.19.3.1 copperjet #!/usr/local/bin/bash [...] # copperjet username and password cjtuser="colin" cjtpass="xxxxxxxxxx" # my PC mypc="venus" # procedure to reset ZIPB mode on the Copperjet resetZIPB () { ( sleep 1 printf "$cjtuser\r" sleep 1 printf "$cjtpass\r" sleep 1 printf "zipb set public device $mypc\r" sleep 1 printf "user logout\r") | telnet copperjet } [...] It works really well. I guess I will have to save studying HTML POST for another project. Thanks anyway for your ideas.-Colin |
|
![]() |
| Outils de la discussion | |
|
|