0

I have the following extract from a script that fetches weather information from accuweather:

wget -O ./weather_raw $address


if [[ -s ./weather_raw ]]; then

egrep 'Currently|Forecast<\/title>|_31x31.gif' ./weather_raw > ./weather
sed -i '/AccuWeather\|Currently in/d' ./weather
sed -i -e 's/^[ \t]*//g' -e 's/<title>\|<\/title>\|<description>\|<\/description>//g' ./weather
sed -i -e 's/&lt;img src="/\n/g' ./weather
sed -i '/^$/d' ./weather
sed -i -e 's/_31x31.*$//g' -e 's/^.*\/icons\///g' ./weather
sed -i -e '1s/.$//' -e '3s/.$//' -e '6s/.$//' ./weather
for (( i=2; i<=8; i+=3 ))
    do
        im=$(sed -n ${i}p ./weather)
        sed -i $i"s/^.*$/$(test_image $im)/" ./weather
    done

fi

The command that triggers the code above is in a conkyrc file and its ~/.conkyblue/accu_weather/rss/acc_rss. When I run the conkyrc script from the prompt, I get an error

sed: can't read /home/me/weather: No such file or directory

And indeed when I check, the "weather" file is not created. However if run the command ~/.conkyblue/accu_weather/rss/acc_rss directly from the prompt, it works as expected and create and puts content into the /home/me/weather file.

I don't know anything about the sed command although I'm trying to learn it as a result of this bother.

What could be the problem with the code. I don't think its a permission issue since the folder its writing into is my home folder and I of-course own it.

Thanks

Napoleon
  • 879
  • 2
  • 14
  • 36

1 Answers1

1

It should have been created by egrep.

When you run your script, the weather directory will be created in the pwd of the script process.

Check and see why egrep does not create the file, or in which directory it created it.

alinsoar
  • 15,386
  • 4
  • 57
  • 74
  • Thanks alinsoar, but I have checked and can't still figure out why its not creating the file. If it any help, I am using fedora 18 – Napoleon Jan 21 '13 at 14:49
  • try to find the file with `find / -name weather`, probably you do not know the working directory of the script. If you know the working directory, check of it has set `+x` [writing access] flag for the user of the script. – alinsoar Jan 21 '13 at 15:12