<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>评论：Shell提问板</title>
	<atom:link href="http://www.igigo.net/shell%e6%8f%90%e9%97%ae%e6%9d%bf/feed" rel="self" type="application/rss+xml" />
	<link>http://www.igigo.net</link>
	<description></description>
	<lastBuildDate>Sat, 04 Feb 2012 01:29:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>由：abel</title>
		<link>http://www.igigo.net/shell%e6%8f%90%e9%97%ae%e6%9d%bf#comment-930</link>
		<dc:creator>abel</dc:creator>
		<pubDate>Thu, 16 Jun 2011 07:35:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.igigo.net/?page_id=62#comment-930</guid>
		<description>#!/usr/bin/expect
spawn echo &quot;1.samba-server 192.168.0.2&quot;
spawn echo &quot;2.sql-server 192.168.0.3&quot;
spawn echo -n &quot;Choose whitch server you want connect :&quot;
read var   #expect不识别这个read var 请问该怎么写？
case $var in
1)
        set ip=192.168.0.2
        set password=123456 ;;
2)
        set ip=192.168.0.3
        set password=123123 ;;
*)
        echo &quot;Only can choose all above !!&quot;
esac
spawn ssh root@ip
expect &quot;*password:*&quot;
send -- &quot;$password\r&quot;</description>
		<content:encoded><![CDATA[<p>#!/usr/bin/expect<br />
spawn echo &#8220;1.samba-server 192.168.0.2&#8243;<br />
spawn echo &#8220;2.sql-server 192.168.0.3&#8243;<br />
spawn echo -n &#8220;Choose whitch server you want connect :&#8221;<br />
read var   #expect不识别这个read var 请问该怎么写？<br />
case $var in<br />
1)<br />
        set ip=192.168.0.2<br />
        set password=123456 ;;<br />
2)<br />
        set ip=192.168.0.3<br />
        set password=123123 ;;<br />
*)<br />
        echo &#8220;Only can choose all above !!&#8221;<br />
esac<br />
spawn ssh root@ip<br />
expect &#8220;*password:*&#8221;<br />
send &#8212; &#8220;$password\r&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>由：igi</title>
		<link>http://www.igigo.net/shell%e6%8f%90%e9%97%ae%e6%9d%bf#comment-925</link>
		<dc:creator>igi</dc:creator>
		<pubDate>Thu, 26 May 2011 02:31:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.igigo.net/?page_id=62#comment-925</guid>
		<description>既然是http, 就没有啥不同, 需要多留意cookie, referer, post的格式，  多用firebug调试吧。无法登录你们到计费网关，我也帮不上了。</description>
		<content:encoded><![CDATA[<p>既然是http, 就没有啥不同, 需要多留意cookie, referer, post的格式，  多用firebug调试吧。无法登录你们到计费网关，我也帮不上了。</p>
]]></content:encoded>
	</item>
	<item>
		<title>由：gipsa</title>
		<link>http://www.igigo.net/shell%e6%8f%90%e9%97%ae%e6%9d%bf#comment-924</link>
		<dc:creator>gipsa</dc:creator>
		<pubDate>Tue, 24 May 2011 13:04:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.igigo.net/?page_id=62#comment-924</guid>
		<description>谢谢IGI，已经将post内容改为：
--post-data=&quot;number=$USER&amp;passwd=$PASS&amp;select=&amp;SELECT&quot;
能够成功登录和注销校图书馆网站了。
但是登录计费网关的那个还是有问题，通过firebug看到的post的数据都写进脚本的post里了，运行脚本则停在下面的状态：
xxx@xxx:~$ ./land_web_wget.sh 
--2011-05-24 20:59:00--  http://172.16.0.3/
Connecting to 172.16.0.3:80... connected.
HTTP request sent, awaiting response... ^C
是否计费网关的登录认证机制和普通的登录认证不同呢？还是别的什么原因？</description>
		<content:encoded><![CDATA[<p>谢谢IGI，已经将post内容改为：<br />
&#8211;post-data=&#8221;number=$USER&amp;passwd=$PASS&amp;select=&amp;SELECT&#8221;<br />
能够成功登录和注销校图书馆网站了。<br />
但是登录计费网关的那个还是有问题，通过firebug看到的post的数据都写进脚本的post里了，运行脚本则停在下面的状态：<br />
xxx@xxx:~$ ./land_web_wget.sh<br />
&#8211;2011-05-24 20:59:00&#8211;  <a href="http://172.16.0.3/" rel="nofollow">http://172.16.0.3/</a><br />
Connecting to 172.16.0.3:80&#8230; connected.<br />
HTTP request sent, awaiting response&#8230; ^C<br />
是否计费网关的登录认证机制和普通的登录认证不同呢？还是别的什么原因？</p>
]]></content:encoded>
	</item>
	<item>
		<title>由：igi</title>
		<link>http://www.igigo.net/shell%e6%8f%90%e9%97%ae%e6%9d%bf#comment-923</link>
		<dc:creator>igi</dc:creator>
		<pubDate>Tue, 24 May 2011 02:28:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.igigo.net/?page_id=62#comment-923</guid>
		<description>我用firebug看了你那个登录页面以及它的代码，它需要post的数据可不只你这两个参数而已

number=xxxx&amp;passwd=xxxx&amp;select=cert_no&amp;returnUrl=

建议你不要屏蔽掉返回的内容，这样就知道提示什么信息了</description>
		<content:encoded><![CDATA[<p>我用firebug看了你那个登录页面以及它的代码，它需要post的数据可不只你这两个参数而已</p>
<p>number=xxxx&#038;passwd=xxxx&#038;select=cert_no&#038;returnUrl=</p>
<p>建议你不要屏蔽掉返回的内容，这样就知道提示什么信息了</p>
]]></content:encoded>
	</item>
	<item>
		<title>由：gipsa</title>
		<link>http://www.igigo.net/shell%e6%8f%90%e9%97%ae%e6%9d%bf#comment-921</link>
		<dc:creator>gipsa</dc:creator>
		<pubDate>Mon, 23 May 2011 08:08:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.igigo.net/?page_id=62#comment-921</guid>
		<description>谢谢IGI的答复，已将脚本修改为：
#! /bin/bash -

HOST_LOGIN=&quot;http://202.195.243.100:8080/uopac/reader/redr_verify.php&quot;
#HOST_LOGIN=&quot;http://202.195.243.100:8080/uopac/reader/login.php&quot;
HOST_VISIT=&quot;http://202.195.243.100:8080/uopac/reader/redr_info.php&quot;
COOKIE=&quot;/tmp/lib.cookie&quot;

USER=&quot;my_name&quot;
PASS=&quot;my_passwd&quot;

#login
wget --keep-session-cookies --save-cookies $COOKIE -O /dev/null --post-data=&quot;number=$USER&amp;passwd=$PASS&quot; $HOST_LOGIN

#verify login status
wget --keep-session-cookies --load-cookies $COOKIE -O verify_lib.html $HOST_VISIT

依然不能得到预期的结果，请问可能是哪个方面的问题呢？</description>
		<content:encoded><![CDATA[<p>谢谢IGI的答复，已将脚本修改为：<br />
#! /bin/bash -</p>
<p>HOST_LOGIN=&#8221;http://202.195.243.100:8080/uopac/reader/redr_verify.php&#8221;<br />
#HOST_LOGIN=&#8221;http://202.195.243.100:8080/uopac/reader/login.php&#8221;<br />
HOST_VISIT=&#8221;http://202.195.243.100:8080/uopac/reader/redr_info.php&#8221;<br />
COOKIE=&#8221;/tmp/lib.cookie&#8221;</p>
<p>USER=&#8221;my_name&#8221;<br />
PASS=&#8221;my_passwd&#8221;</p>
<p>#login<br />
wget &#8211;keep-session-cookies &#8211;save-cookies $COOKIE -O /dev/null &#8211;post-data=&#8221;number=$USER&amp;passwd=$PASS&#8221; $HOST_LOGIN</p>
<p>#verify login status<br />
wget &#8211;keep-session-cookies &#8211;load-cookies $COOKIE -O verify_lib.html $HOST_VISIT</p>
<p>依然不能得到预期的结果，请问可能是哪个方面的问题呢？</p>
]]></content:encoded>
	</item>
	<item>
		<title>由：igi</title>
		<link>http://www.igigo.net/shell%e6%8f%90%e9%97%ae%e6%9d%bf#comment-920</link>
		<dc:creator>igi</dc:creator>
		<pubDate>Mon, 23 May 2011 02:26:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.igigo.net/?page_id=62#comment-920</guid>
		<description>1. 登录的url就是 action=&#039;xxx&#039;指定的地址
   打开一个登录页面时，当前的url只不过是呈现给用户的交互界面，此时并未产生登录操作，而form指定的action才是登录的接口

2. wget所指定的cookie只不过是个存放cookie的文件，位置并不重要

3. 你没有用load-cookie选项来加载登录成功后的cookie，所以不成功不奇怪。</description>
		<content:encoded><![CDATA[<p>1. 登录的url就是 action=&#8217;xxx&#8217;指定的地址<br />
   打开一个登录页面时，当前的url只不过是呈现给用户的交互界面，此时并未产生登录操作，而form指定的action才是登录的接口</p>
<p>2. wget所指定的cookie只不过是个存放cookie的文件，位置并不重要</p>
<p>3. 你没有用load-cookie选项来加载登录成功后的cookie，所以不成功不奇怪。</p>
]]></content:encoded>
	</item>
	<item>
		<title>由：gipsa</title>
		<link>http://www.igigo.net/shell%e6%8f%90%e9%97%ae%e6%9d%bf#comment-918</link>
		<dc:creator>gipsa</dc:creator>
		<pubDate>Sat, 21 May 2011 13:49:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.igigo.net/?page_id=62#comment-918</guid>
		<description>网络计费系统登录页面的form如下：
(form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;http://172.16.0.3/&quot;)
...
(input name=&quot;DDDDD&quot; type=&quot;text&quot; id=&quot;DDDDD&quot; value=&quot;&quot; size=&quot;22&quot;)
...
(input name=&quot;upass&quot; type=&quot;password&quot; id=&quot;upass&quot; size=&quot;12&quot; maxlength=&quot;10&quot;)
...
(/form)</description>
		<content:encoded><![CDATA[<p>网络计费系统登录页面的form如下：<br />
(form name=&#8221;form1&#8243; method=&#8221;post&#8221; action=&#8221;http://172.16.0.3/&#8221;)<br />
&#8230;<br />
(input name=&#8221;DDDDD&#8221; type=&#8221;text&#8221; id=&#8221;DDDDD&#8221; value=&#8221;" size=&#8221;22&#8243;)<br />
&#8230;<br />
(input name=&#8221;upass&#8221; type=&#8221;password&#8221; id=&#8221;upass&#8221; size=&#8221;12&#8243; maxlength=&#8221;10&#8243;)<br />
&#8230;<br />
(/form)</p>
]]></content:encoded>
	</item>
	<item>
		<title>由：gipsa</title>
		<link>http://www.igigo.net/shell%e6%8f%90%e9%97%ae%e6%9d%bf#comment-917</link>
		<dc:creator>gipsa</dc:creator>
		<pubDate>Sat, 21 May 2011 13:43:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.igigo.net/?page_id=62#comment-917</guid>
		<description>您好，shell新手（描述不贴切的地方，请见谅并指出），与‘思绪纷飞’同样需求，Shell下自动填写表单，登录学校图书馆网站，然后抓取用户信息页面。用的是wget，未成功，脚本如下：

#! /bin/bash -

HOST_LOGIN=&quot;http://202.195.243.100:8080/uopac/reader/redr_verify.php&quot;
#HOST_LOGIN=&quot;http://202.195.243.100:8080/uopac/reader/login.php&quot;
HOST_VISIT=&quot;http://202.195.243.100:8080/uopac/reader/redr_info.php&quot;
COOKIE=&quot;/tmp/lib.cookie&quot;

USER=&quot;my_name&quot;
PASS=&quot;my_password&quot;

#login
wget --keep-session-cookies --save-cookies=$COOKIE -O /dev/null --post-data=&quot;number=$USER&amp;passwd=$PASS&quot; $HOST_LOGIN

#verify login status
wget --keep-session-cookies --save-cookies=$COOKIE -O verify_lib.html $HOST_VISIT

其中，已经注意了以下几点：
1.用户名、密码和相关URL无误；
2.--post-data所传的name/value对中的name为登录页面上表单中对应输入框的name值；
3.验证是否登录成功：若成功，则第二次使用wget得到的页面中应该包含我的用户信息，事实上，脚本运行后在verify_lib.html中得到的仍为提示登录的页面信息。

不明白的地方如下：
1.脚本代码中注释掉的HOST_LOGIN为登录页面的URL，未注释的HOST_LOGIN为登录页面上form内action所指定的URL（action=&quot;redr_verify.php&quot;）。究竟应该用哪个？（根据您给出脚本样例，应该用未注释掉的，但是因为我没有搞定，故有此疑问。）
2.cookie的位置由我自定义，对吗？
3.为什么此脚本没能成功登录？

注：
1.我的主机系统：Ubuntu 10.04
2.我本想用wget登录学校的网络计费系统（校园网免费使用，登录计费系统后，可以访问外网，按时间计费），这个是否与cookie无关？用wget实现的话，有哪些需要注意的地方呢？
网络计费系统登录页面的form如下：

...

...

...


谢谢！
如果您希望私下回答这些问题，请发邮件到gipsa.liu#gmail.com，非常感谢您的指导！</description>
		<content:encoded><![CDATA[<p>您好，shell新手（描述不贴切的地方，请见谅并指出），与‘思绪纷飞’同样需求，Shell下自动填写表单，登录学校图书馆网站，然后抓取用户信息页面。用的是wget，未成功，脚本如下：</p>
<p>#! /bin/bash -</p>
<p>HOST_LOGIN=&#8221;http://202.195.243.100:8080/uopac/reader/redr_verify.php&#8221;<br />
#HOST_LOGIN=&#8221;http://202.195.243.100:8080/uopac/reader/login.php&#8221;<br />
HOST_VISIT=&#8221;http://202.195.243.100:8080/uopac/reader/redr_info.php&#8221;<br />
COOKIE=&#8221;/tmp/lib.cookie&#8221;</p>
<p>USER=&#8221;my_name&#8221;<br />
PASS=&#8221;my_password&#8221;</p>
<p>#login<br />
wget &#8211;keep-session-cookies &#8211;save-cookies=$COOKIE -O /dev/null &#8211;post-data=&#8221;number=$USER&amp;passwd=$PASS&#8221; $HOST_LOGIN</p>
<p>#verify login status<br />
wget &#8211;keep-session-cookies &#8211;save-cookies=$COOKIE -O verify_lib.html $HOST_VISIT</p>
<p>其中，已经注意了以下几点：<br />
1.用户名、密码和相关URL无误；<br />
2.&#8211;post-data所传的name/value对中的name为登录页面上表单中对应输入框的name值；<br />
3.验证是否登录成功：若成功，则第二次使用wget得到的页面中应该包含我的用户信息，事实上，脚本运行后在verify_lib.html中得到的仍为提示登录的页面信息。</p>
<p>不明白的地方如下：<br />
1.脚本代码中注释掉的HOST_LOGIN为登录页面的URL，未注释的HOST_LOGIN为登录页面上form内action所指定的URL（action=&#8221;redr_verify.php&#8221;）。究竟应该用哪个？（根据您给出脚本样例，应该用未注释掉的，但是因为我没有搞定，故有此疑问。）<br />
2.cookie的位置由我自定义，对吗？<br />
3.为什么此脚本没能成功登录？</p>
<p>注：<br />
1.我的主机系统：Ubuntu 10.04<br />
2.我本想用wget登录学校的网络计费系统（校园网免费使用，登录计费系统后，可以访问外网，按时间计费），这个是否与cookie无关？用wget实现的话，有哪些需要注意的地方呢？<br />
网络计费系统登录页面的form如下：</p>
<p>&#8230;</p>
<p>&#8230;</p>
<p>&#8230;</p>
<p>谢谢！<br />
如果您希望私下回答这些问题，请发邮件到gipsa.liu#gmail.com，非常感谢您的指导！</p>
]]></content:encoded>
	</item>
	<item>
		<title>由：igi</title>
		<link>http://www.igigo.net/shell%e6%8f%90%e9%97%ae%e6%9d%bf#comment-915</link>
		<dc:creator>igi</dc:creator>
		<pubDate>Mon, 16 May 2011 10:48:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.igigo.net/?page_id=62#comment-915</guid>
		<description>chenwqin :!: gmail.com</description>
		<content:encoded><![CDATA[<p>chenwqin <img src='http://www.igigo.net/wp-includes/images/smilies/icon_exclaim.gif' alt=':!:' class='wp-smiley' />  gmail.com</p>
]]></content:encoded>
	</item>
	<item>
		<title>由：tomoya</title>
		<link>http://www.igigo.net/shell%e6%8f%90%e9%97%ae%e6%9d%bf#comment-914</link>
		<dc:creator>tomoya</dc:creator>
		<pubDate>Sun, 15 May 2011 09:06:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.igigo.net/?page_id=62#comment-914</guid>
		<description>感谢!!!提问的时候太心急了,没看到您在上面说过作业题不予解答,虽然我本人认为这不是作业题,不过严格意义上来说也算了,看到您的解答,我受益匪浅,真的太感谢了!
不知道方便今后联系么?没看到您的邮箱,就留下我的了.</description>
		<content:encoded><![CDATA[<p>感谢!!!提问的时候太心急了,没看到您在上面说过作业题不予解答,虽然我本人认为这不是作业题,不过严格意义上来说也算了,看到您的解答,我受益匪浅,真的太感谢了!<br />
不知道方便今后联系么?没看到您的邮箱,就留下我的了.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

