LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-12-2010, 12:59 AM   #1
Kakarot_Rathish
Member
 
Registered: Sep 2008
Posts: 35
Blog Entries: 1

Rep: Reputation: 15
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
 
Old 04-12-2010, 01:15 AM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Kakarot_Rathish View Post
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.
 
Old 04-13-2010, 01:08 AM   #3
Kakarot_Rathish
Member
 
Registered: Sep 2008
Posts: 35
Blog Entries: 1

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Sergei Steshenko View Post
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 ?.
 
Old 04-13-2010, 01:39 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Kakarot_Rathish View Post
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).
 
Old 04-13-2010, 02:31 AM   #5
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,563

Rep: Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939
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.
 
Old 04-13-2010, 04:06 AM   #6
Kakarot_Rathish
Member
 
Registered: Sep 2008
Posts: 35
Blog Entries: 1

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by grail View Post
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

Last edited by Kakarot_Rathish; 04-13-2010 at 04:08 AM.
 
  


Reply

Tags
command, found, wget


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wget command runs manually but over cron doesnt ulver Linux - Newbie 3 12-24-2009 04:26 AM
Page break command gubak Linux - Newbie 1 03-13-2007 04:27 AM
What command to type on frozen run scan disc manually page jerryjg Mandriva 5 01-02-2006 08:53 PM
HTML page break? patpawlowski Programming 4 02-12-2004 10:30 AM
wget command not found irs-away Linux - Newbie 4 09-07-2003 10:35 AM


All times are GMT -5. The time now is 07:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration