[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next date => thread ]
Hey Paul,
Your approach is actually pretty close! Using sed to remove the first line works, though there are a few ways to make this cleaner and more robust.
For tracking which URL you've posted, I'd suggest keeping a simple counter in a separate file rather than modifying your URL list each time. That way you keep your original list intact and can easily reset or adjust things. Something like:
One thing to consider - if you want this cycling forever, you might want to add logic to reset the counter when it reaches the end of your list. Also worth having the script log its output somewhere so you can check it's actually running.
Does that help point you in the right direction?
Cheers,
-Tim
Hi
I am trying to write a shell script that when run will read a text file,
which contains a list e.g
item1
item2
item3
and for now echo the first line to stdout and in the case of what I have
send to another text file
#display first line of a file
head -n 1 lines.txt > topline.txt
#delete first line of a file
sed -i -e "1d" lines.txt
cat topline.txt
But I don't think this is at all the correct way to do this. I am
trying to find out how, but
The ultimate aim of will be to
Take a text file or list of urls (lets say Code Club Activities)
Run the script say, every monday at 02:00 am
each time the script is run, it will use the toot (mastodon cli tool) to
send that url to a Mastodon account.
then the next time it is run, send the next url in the list.
I think I need to start by identifying the correct way to do this, then
write or get help writing the a script to do this.
I should not have a program getting a shell script to run at an allotted
time each week using cron.
So for example
https://projects.raspberrypi.org/en/projects/space-talk
https://projects.raspberrypi.org/en/projects/catch-the-bus
https://projects.raspberrypi.org/en/projects/find-the-bug
https://projects.raspberrypi.org/en/projects/silly-eyes
https://projects.raspberrypi.org/en/projects/surprise-animation
I had some help before with regard to reading an array containing a list
of files, which then runs on all entries in the array. However, in this
case the script will run and act on the first item, then run again a
week later and act on the 2nd item.
So it needs a way to track which item to send.
So over a period of 5/6 weeks I send out a different activity each week.
However, I also appreciate that sending out just a url is not very
friendly or helpful, so there should be some text wrapped around it.
I could perhaps create a series of text files with url and wrapper text.
Hopefully, this can be run on a Raspberry pi, and it can just be left
on and do tasks at allotted times.
Could someone help / advise please.
Thanks for any help
Paul
--
Paul Sutton, Cert Cont Sci (Open)
https://zleap.net/
Mastodon : https://techhub.social/@zleap
--
The Mailing List for the Devon & Cornwall LUG
FAQ: https://www.dcglug.org.uk/faq/
-- The Mailing List for the Devon & Cornwall LUG FAQ: https://www.dcglug.org.uk/faq/