It's a good idea to use variables for storing the filenames used.
It's also a good idea to use an absolute path when accessing the file.
eg:

my_user = "voytek"
ccc_final = "/var/tmp/ccc"
ccc_html = "http:.../ccc.html"
ccc_txt = "/var/tmp/ccc.txt"
ccc_bod = "/var/tmp/ccc.bod"

wget ... $ccc_html
...
links -dump $ccc_html > $ccc_txt
...
awk '/Page/, /References/  { print }' $ccc_txt  > $ccc_bod
...
mail -s "ccc list" $my_user < $ccc_final

etc.

Chris-

On Mon, May 9, 2011 at 8:59 AM, Voytek Eymont <li...@sbt.net.au> wrote:
> I'm trying to put together a basic script, it works fine when I run it as
> root, but, I'm having issues when I try to run as 'voytek'
>
> $ ls -al /usr/local/bin/ccc
> -rwxr-x--- 1 root voytek 1409 May  9 08:19 /usr/local/bin/ccc
>
>
> /usr/local/bin/ccc: line 16: ccc.txt: Permission denied
> mv: overwrite `ccc.old', overriding mode 0644?
> rm: remove write-protected regular file `logout.html'?
> rm: remove write-protected regular file `logout.html'?
> logout.html: Permission denied
>
>
> script fetches a html page, parses it several times, then emails some text
> from it
>
> when starting the script should I say 'cd /var/tmp' (to have temp files
> in/var/tmp?)
>
> should I prefix full path to intermediate files ( /var/tmp/body.txt?)
>
> -------------------------------
> wget .... http://dom.tld/main.htm
> wget .... ccc.html
>
> echo "dump to text, get rid of blanks "
> links -dump ccc.html > ccc.txt
>
> ## get rid of blank lines
> awk '/Page/, /References/  { print }' ccc.txt  > ccc.bod
>
> ## Better remove all leading and trailing whitespace from end of each line:
> sed 's/^[ \t]*//;s/[ \t]*$//' ccc.bod > ccc.1
>
> # delete lines matching pattern
> sed '/INT/d' ccc.1 > ccc
>
> mail -s "ccc list" voytek < ccc
>
> mv ccc ccc.old
> rm main.htm
> rm logout.html
> rm ccc.1
> rm ccc.bod
> rm ccc.html
> rm logout.html
> rm my-cookies
>
> -------------------------------
>
> --
> Voytek
>
>
> --
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
>
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to