LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 02-12-2013, 06:09 AM   #1
vk4led
LQ Newbie
 
Registered: Dec 2011
Posts: 18

Rep: Reputation: Disabled
Cut Text from Webpage - Weather


Howdy

I have a script that works well with retreiving weather information from a webpage. If then tailors it to how I want it then spits it out as email.

I have the script working under CentOS, however I have just converted it over to Debian

The script works all the way up until it is required to "cut" information obtained and place it into a file for editing.

************************* FROM SCRIPT ******************

echo "Location supplied = "$place
echo "------------------------------------"
interest=0
while read line; do # loop to step through pages
pagenumber=`echo $line | cut -b 0-8`
pagename=`echo $line | cut -b 11-`
echo "Scanning -----> "$pagenumber" <----- "
**************************************************************

It gets to the "cut" section and spits out"

cut: fields and positions are numbers from 1
Try `cut --help' for more information

I am sure there is a simple answer for this, however I am puzzled as to why it falters on this "cut" command - when it was working so well under CentOS

Many thanks for reading this.
 
Old 02-12-2013, 07:35 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
Hi

This line is buggy:

Quote:
pagenumber=`echo $line | cut -b 0-8`
That cut command take a range of bytes, 1 meaning the first byte. So using 0 here is incorrect.

http://linux.die.net/man/1/cut

It doesn't say what should happen if the numbers are incorrect. My guess is that some other versions of cut simply ignores it, and uses 1 instead, while others give an error message.

Try changing the line to this:

Quote:
pagenumber=`echo $line | cut -b 1-8`
 
1 members found this post helpful.
Old 02-12-2013, 03:59 PM   #3
vk4led
LQ Newbie
 
Registered: Dec 2011
Posts: 18

Original Poster
Rep: Reputation: Disabled
Thanks for the short and swift answer! Funny how some of these things you keep looking at and it is staring you right in the face!

Appreciated
 
  


Reply



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
[SOLVED] Extracting Text from file... Weather information vk4led Linux - Newbie 13 09-13-2012 05:58 AM
[SOLVED] Bash command to 'cut' text into another text file & modifying text. velgasius Programming 4 10-17-2011 04:55 AM
Uploading a text into a webpage from command line frenchn00b Linux - General 2 04-01-2011 03:42 PM
Display text of webpage from terminal billamn Linux - Newbie 5 08-18-2006 10:21 PM
Text Terminals Cut Off nagloc Linux - General 2 08-20-2004 08:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 12:25 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration