2013-09-30 83 views
0

我使用curl執行獲取操作。 (此鏈接將發出服務器重啓)捲曲不執行動作

curl -v -u username:password http://example.com/index.html?process=waterServer&action=restart 

似乎curl忽略了請求中的操作部分。我得到的輸出,

* Trying example.com... connected 
* Server auth using Basic with user 'username' 
> GET /index.html?process=waterServer HTTP/1.1 
> Authorization: BasiC############# 
> User-Agent: bla bla bla 
> Host: example.com 
> Accept: */* 

然後輸出HTML頁面,並用線

[1] +完成捲曲-v -u用戶名結束:密碼http://example.com/index.html?process=waterServer

它是正確的行爲?如果上面的鏈接複製粘貼到瀏覽器上,它會詢問用戶名/密碼並重新啓動服務器。

回答

0

正確的選項在Ubuntu的工作是-d。現在要執行的命令是,

curl -L -u username:password http://example.com/index.html? -d process=waterServer -d action=restart 

-L是得到重定向頁面。

0

你必須在URL參數中跳過你的'&'。

捲曲-v -u用戶名:密碼http://example.com/index.html?process=waterServer^&行動=重啓

如果不行嘗試使用curl --data-進行urlencode

+0

它沒有工作。我得到相同的輸出'> GET /index.html?process=waterServer^ HTTP/1.1> .'最後一行相同'[1] +完成curl -v -L -u用戶名:密碼http://example.com/ index.html?process = waterServer ^' – Netro

+0

好吧,轉義取決於您使用的操作系統。 –

+0

它的Ubuntu的1104 – Netro