I use an init script to log in my ISP. The script is like this
wget -O - --post-data 'username=...&password=...' 'http://....' |
html2text | tee /tmp/$$.txt
fgrep -q 'already logged in' /tmp/$$.txt || exit 1
unlink /tmp/$$.txt
(The username and password are public in this building, so I need not worry about the clear-text password.)

It was strange that /tmp/$$.txt apparently contained the string “already logged in” but the script always exited abnormally (fgrep fails).

I finally found the reason by opening /tmp/$$.txt with bvi (a vi-style hexadecimal editor): the string in the file was actually like this: “You a\bare alr\bread\bdy logged\bd in.” (“\b” stands for backspace character.) That’s why fgrep could not find the string..

html2text sucks.

No comments:

Post a Comment