LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   saving a page using wget+command -O not found+each time i'v to break manually (http://www.linuxquestions.org/questions/programming-9/saving-a-page-using-wget-command-o-not-found-each-time-iv-to-break-manually-801469/)

Kakarot_Rathish 04-12-2010 12:59 AM

saving a page using wget+command -O not found+each time i'v to break manually
 
i'm trying to save a page from a university website having results of a student using wget command.
When i run the command from terminal,it saves a file but then it just waits,or the cursor keeps blinking i had to manually break it using "ctrl+c".
What will be the reason? can anyone help me out, my project submission date is next week and this is an important step in it.

=========================================
Station71:~# wget -U MyBrowser/1.0 http://210.212.226.132/exams/results...&Submit=Submit -O /root/example.html
[1] 3882
bash: -O: command not found

Station71:~# --11:01:10-- http://210.212.226.132/exams/results...gno=mkageit010
=> `BT5555newdisplay.php?regno=mkageit010'
Connecting to 172.16.0.254:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]

[ <=> ] 4,118 --.--K/s

11:01:11 (22.66 MB/s) - `BT5555newdisplay.php?regno=mkageit010' saved [4118]

//used ctrl+c

[1]+ Done wget -U MyBrowser/1.0 http://210.212.226.132/exams/results...gno=mkageit010

======================

Similarly i used to save the page as /root/example.html using option "-O" earlier and it used to work fine,but now it is reporting as command -O not found.
What can be the problem with that.


Thankyou

Sergei Steshenko 04-12-2010 01:15 AM

Quote:

Originally Posted by Kakarot_Rathish (Post 3932497)
i'm trying to save a page from a university website having results of a student using wget command.
When i run the command from terminal,it saves a file but then it just waits,or the cursor keeps blinking i had to manually break it using "ctrl+c".
What will be the reason? can anyone help me out, my project submission date is next week and this is an important step in it.

=========================================
Station71:~# wget -U MyBrowser/1.0 http://210.212.226.132/exams/results...&Submit=Submit -O /root/example.html
[1] 3882
bash: -O: command not found

Station71:~# --11:01:10-- http://210.212.226.132/exams/results...gno=mkageit010
=> `BT5555newdisplay.php?regno=mkageit010'
Connecting to 172.16.0.254:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]

[ <=> ] 4,118 --.--K/s

11:01:11 (22.66 MB/s) - `BT5555newdisplay.php?regno=mkageit010' saved [4118]

//used ctrl+c

[1]+ Done wget -U MyBrowser/1.0 http://210.212.226.132/exams/results...gno=mkageit010

======================

Similarly i used to save the page as /root/example.html using option "-O" earlier and it used to work fine,but now it is reporting as command -O not found.
What can be the problem with that.


Thankyou

The problem is that your URL contains special characters (like '&'), and the shell interprets them in a special way.

Put your URL in quotes or use backslash to escape the characters.

Kakarot_Rathish 04-13-2010 01:08 AM

Quote:

Originally Posted by Sergei Steshenko (Post 3932510)
The problem is that your URL contains special characters (like '&'), and the shell interprets them in a special way.

Put your URL in quotes or use backslash to escape the characters.

Thank you.
In terminal it worked.I'm implementing it in java using NETBEANS IDE.

I used the following code
==================================
String cmd ="wget -U MyBrowser/1.0 http://210.212.226.132/exams/results1/btechNEW/BT5555newdisplay.php?regno=mkageit010\\&Submit=Submit";
System.out.println(cmd);
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
System.out.println(cmd);
BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = "";
while ((line=buf.readLine())!=null) {
System.out.println(line);}
==================================

The output when i ran was
===============================
run:
wget -U MyBrowser/1.0 http://210.212.226.132/exams/results...&Submit=Submit
wget -U MyBrowser/1.0 http://210.212.226.132/exams/results...&Submit=Submit
BUILD STOPPED (total time: 15 seconds)
================================

I had to manually stop the running as it was not getting completed.
What i figured out is that,there is some problem in reading the inputstream.But as i'm beginner in java,i'm unable to understand why ?.

Sergei Steshenko 04-13-2010 01:39 AM

Quote:

Originally Posted by Kakarot_Rathish (Post 3933668)
Thank you.
In terminal it worked.I'm implementing it in java using NETBEANS IDE.

I used the following code
==================================
String cmd ="wget -U MyBrowser/1.0 http://210.212.226.132/exams/results1/btechNEW/BT5555newdisplay.php?regno=mkageit010\\&Submit=Submit";
System.out.println(cmd);
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
System.out.println(cmd);
BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = "";
while ((line=buf.readLine())!=null) {
System.out.println(line);}
==================================

The output when i ran was
===============================
run:
wget -U MyBrowser/1.0 http://210.212.226.132/exams/results...&Submit=Submit
wget -U MyBrowser/1.0 http://210.212.226.132/exams/results...&Submit=Submit
BUILD STOPPED (total time: 15 seconds)
================================

I had to manually stop the running as it was not getting completed.
What i figured out is that,there is some problem in reading the inputstream.But as i'm beginner in java,i'm unable to understand why ?.

I am not a Java guy. Anyway, where from this line:

Code:

while ((line=buf.readLine())!=null)
is supposed to read ?

Please use CODE tags (use "Go advanced" menu option, mark the code with mouse and press '#' button or put the tags manually).

grail 04-13-2010 02:31 AM

So just to confirm, your original query:
Quote:

saving a page using wget+command -O not found+each time i'v to break manually
i'm trying to save a page from a university website having results of a student using wget command.
When i run the command from terminal,it saves a file but then it just waits,or the cursor keeps blinking i had to manually break it using "ctrl+c".
What will be the reason? can anyone help me out, my project submission date is next week and this is an important step in it.

=========================================
Station71:~# wget -U MyBrowser/1.0 http://210.212.226.132/exams/results...&Submit=Submit -O /root/example.html
[1] 3882
bash: -O: command not found

Station71:~# --11:01:10-- http://210.212.226.132/exams/results...gno=mkageit010
=> `BT5555newdisplay.php?regno=mkageit010'
Connecting to 172.16.0.254:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]

[ <=> ] 4,118 --.--K/s

11:01:11 (22.66 MB/s) - `BT5555newdisplay.php?regno=mkageit010' saved [4118]

//used ctrl+c

[1]+ Done wget -U MyBrowser/1.0 http://210.212.226.132/exams/results...gno=mkageit010

======================

Similarly i used to save the page as /root/example.html using option "-O" earlier and it used to work fine,but now it is reporting as command -O not found.
What can be the problem with that.


Thankyou
Is completely misleading as your issue has nothing to do with wget and that you have to terminate with Ctrl+C, but rather that your Netbeans / Java program is
not working and needs to be terminated with Ctrl+C. It may help if you ask your actual question.

I am only mentioning as at the time I originally looked at this question, prior to Sergei's first post, I ran your code and was
about to come back and say it works just fine at my command prompt, but now realise I wasted my time.

Kakarot_Rathish 04-13-2010 04:06 AM

Quote:

Originally Posted by grail (Post 3933746)
So just to confirm, your original query:


Is completely misleading as your issue has nothing to do with wget and that you have to terminate with Ctrl+C, but rather that your Netbeans / Java program is
not working and needs to be terminated with Ctrl+C. It may help if you ask your actual question.

I am only mentioning as at the time I originally looked at this question, prior to Sergei's first post, I ran your code and was
about to come back and say it works just fine at my command prompt, but now realise I wasted my time.

The wget command worked fine when i used backslash in front of the special character.
It was not working as i mentioned in my original query.
And my second question was about the -O option,it used to work fine till last week,now it returned bad command.
And i ran this commands in terminal to check if they are working so that i can implement them in my java project.
But it is not working in my project.
When i press the button to perform the action,it just hangs there and as i mentioned,i think it is stuck when reading from the inputstream

Thankyou


All times are GMT -5. The time now is 11:52 AM.