D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG]Re: writing shell scripts

 

Have you tried asking a coding AI assistant ?

I've used github co-pilot to write all kinds of scripts for me, it is astonishingly easy, although be sure to check the code before deploying it.



Sent from my Galaxy


-------- Original message --------
From: Paul Sutton via list <list@xxxxxxxxxxxxx>
Date: 24/10/2025 16:36 (GMT+00:00)
To: DCGLUG <list@xxxxxxxxxxxxx>
Cc: Paul Sutton <zleap@xxxxxxxxxxx>
Subject: [LUG]writing shell scripts

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/