Sponsored Content
Top Forums Shell Programming and Scripting Shell script for weather / forecast Post 302468315 by yamirokuay on Tuesday 2nd of November 2010 10:28:36 AM
Old 11-02-2010
Shell script for weather / forecast

Code:
#!/bin/sh
#Argentina Only :s
# This script requires curl and iconv, iconv is because they do not use Weather Service utf-8 ¬¬
# 87938 = Ushuaia
# 87934 = Rio Grande
# 87418 = Mendoza
# 87582 = Capital Federal
# 87692 = Mar del Plata
# 87480 = Rosario
# 87344 = Cordoba
# 87371 = Santa Fe

# Ciudad predeterminada
ciudad=87934
if [ $# -ge 1 ] ; then
  ciudad=$1
fi

URL="http://www.smn.gov.ar/?mod=dpd&id=21&e="$ciudad
TXT="$HOME/Documentos/Pronostico/pronostico.txt"

curl -s "$URL" | grep 'TEMPERATURA: ' | sed -re 's/|&nbsp;|<[a-zA-Z\/][^>]*>|  |\t//g' | iconv --from-code=ISO-8859-1 --to-code=UTF-8 > $TXT

#estad=`grep 'ESTADO DEL TIEMPO' $TXT | sed -re 's/.*: (.*)/\1/'`
#visib=`grep 'VISIBILIDAD:' $TXT | sed -re 's/.*: (.*)/\1/'`
#sensa=`grep 'SENSACION:' $TXT | sed -re 's/.*: (.*)/\1/'`
tempe=`grep 'TEMPERATURA:' $TXT | sed -re 's/.*: (.*)/\1/'`
#humed=`grep 'HUMEDAD:' $TXT | sed -re 's/.*:  (.*)/\1/'`
#presi=`grep 'PRESION:' $TXT | sed -re 's/.*: (.*)/\1/'`
#vient=`grep 'VIENTO:' $TXT | sed -re 's/.*: (.*)/\1/'`
#hora=`grep '.*Hora:' $TXT | sed -re 's/.*: (.*)Horas\./\1/'`
#dia=`grep '.*Dia:' $TXT | sed -re 's/.*: (.*)/\1/'`

sed 's/'ºC'//g' pronostico.txt
sed 's/'TEMPERATURA:'//g' pronosticotmp.txt > temperatura.txt


#Opcional
#tempe=`echo $tempe | tr '.' ','`

#echo "$tempe ($sensa) - $humed humed. - viento: $vient - presión: $presi - visib: $visib - $estad ($dia $hora)" | sed 's/  / /g'



-----------------------------------------------------------------------
The last script works fine, but the only bad thing is that I leave a blank space that I can not erase. And try a thousand ways I could not make it work.

 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to check weather file is blank or not?

Dear All I want to do following task. Kindly suggest. In my script every hour one file is genarated. say xyz.txt. Now if this file contain some data then i want to do task A and if file is blank then i want to do nothing. Kindly help me to do this. regards jaydeep (5 Replies)
Discussion started by: jaydeep_sadaria
5 Replies

2. UNIX for Dummies Questions & Answers

How to verify weather it is a ebcdic file or not

Hi all, Please tell me how to verify weather it is a ebcdic file or not . I checked with file commond but it is giving like International Language text. Regards, Chaitu (0 Replies)
Discussion started by: c_chaitanya
0 Replies

3. Linux

Check weather a file is in use or not?

Hi, Hi want to check weather a file is being used by using a command or java code or shell script. So, can any body give me some idea.. Thanks Buddhika (3 Replies)
Discussion started by: cse.buddhika
3 Replies

4. Shell Programming and Scripting

Geo Weather Challenge

Hi everybody, I'm new to these forums and this is my first post. A couple days ago I was trying to find a simple script that would return an individual's local weather conditions using I.P. based geolocation. After many failed search attempts, I began my quest to create this for myself. I have to... (0 Replies)
Discussion started by: o0110o
0 Replies

5. Shell Programming and Scripting

Use PYTHON to collect data weather and print in new file

Hi all, i have a task to do with Python and because i'm a beginner on it i would like your help on this. Create a python script that: Every hour collect the Temperature (e.g. 29C) and Current Condition (e.g. Clear) from this website wunderground.com/global/stations/54511.html Create a CSV... (0 Replies)
Discussion started by: ragaga123
0 Replies

6. Shell Programming and Scripting

Looking for a return value weather smartctl is running a (short) selftest or not

Hey guys, I'm kinda stuck here.. I'm trying to write a script, which should start a short selftest via smartctl, for example smartctl -t short /dev/sda and after the test is finished I want it to write the new smartvalues in a logfile. well... Now I need a return value for wether the... (1 Reply)
Discussion started by: phill971
1 Replies

7. Shell Programming and Scripting

Forecast of jobs

Hello, I'm looking for forecast of Autosys Jobs, along with their status, in a specific time period. I tried job_depends and autorep. Problem with autorep is, I Cannot use from and to time, like I can use with job_depends, but the results are in a simple single line format for each job,... (0 Replies)
Discussion started by: rajaram.m
0 Replies
Weather::Com::DayForecast(3pm)				User Contributed Perl Documentation			    Weather::Com::DayForecast(3pm)

NAME
Weather::Com::DayForecast - class representing a forecast for one day SYNOPSIS
[...] my @locations = $weather_finder->find('Heidelberg'); my $forecast = $locations[0]->forecast(); my $tomorrow = $forecast->day(1); print "Forecast for tomorrow: "; print " - tomorrow it's the ", $tomorrow->date()->date(), " "; print " - sunrise will be at ", $tomorrow->sunrise()->time(), " "; print " - maximum temperature will be ", $tomorrow->high(), " "; DESCRIPTION
Via Weather::Com::DayForecast objects one can access the weather forecast for one specific day. This class will not be updated automatically with each call to one of its methods. You need to call a method of your Weather::Com::Forecast object to get updated objects. CONSTRUCTOR
You usually would not construct an object of this class yourself. This is implicitely done when you call the "day(number of day)" or the "all()" method of a Weather::Com::Forecast object. METHODS
date() Returns a Weather::Com::DateTime object containing the date the forecast is for. high() Returns the maximum temperature that will be reached at daytime. For day 0 (today), this will be 'N/A' when it's after noon... There is a bug in weather.com's date and time mathematics: If you are asking for a location's forecast day 0 and it's short after midnight, day 0 will be "yesterday" and you'll get both, yesterday's daytime forecast and night forecast! I have not investigated this issue further, yet. If anyone has, please inform me! low() Returns the minimum temperature that will be reached at night. sunrise() Returns a Weather::Com::DateTime object containing the time of sunrise. sunset() Returns a Weather::Com::DateTime object containing the time of sunset. day() Returns a Weather::Com::DayPart object with all data belonging to the daytime. For day 0 (today), this will be "undef" when it's after noon... There is a bug in weather.com's date and time mathematics: If you are asking for a location's forecast day 0 and it's short after midnight, day 0 will be "yesterday" and you'll get both, yesterday's daytime forecast and night forecast! I have not investigated this issue further, yet. If anyone has, please inform me! night() Returns a Weather::Com::DayPart object with all data belonging to the night. AUTHOR
Thomas Schnuecker, <thomas@schnuecker.de> COPYRIGHT AND LICENSE
Copyright (C) 2004-2007 by Thomas Schnuecker This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The data provided by weather.com and made accessible by this OO interface can be used for free under special terms. Please have a look at the application programming guide of weather.com (<http://www.weather.com/services/xmloap.html>)! perl v5.8.8 2007-07-09 Weather::Com::DayForecast(3pm)
All times are GMT -4. The time now is 07:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy