D&C GLug - Home Page

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

[LUG] Bash scripting magic needed

 

Hi

I am experimenting with the command line mastodon client toot

If I save some text in for example toot.txt then run

toot post < toot.txt

The content of toot.txt is posted to Mastodon (as expected)

Posting pictures however is a two step process

1. run toot upload file.png

will give me the following

Successfully uploaded media ID 105448798680946910, type 'image'
Original URL: https://storage.gra.cloud.ovh.net/v1/AUTH_011f6e315d3744d498d93f6fa0d9b5ee/qotoorg/media_attachments/files/105/448/798/680/946/910/original/27bd608eb6e11dab.png Preview URL: https://storage.gra.cloud.ovh.net/v1/AUTH_011f6e315d3744d498d93f6fa0d9b5ee/qotoorg/media_attachments/files/105/448/798/680/946/910/small/27bd608eb6e11dab.png
Text URL:     https://qoto.org/media/nDWr_rzPjQbyxsh6ikA


In general I can manually copy / paste a url from the above to a toot.

However doing this from the command line,

toot upload file.png > picture.txt which produces a text file containing similar text to the above.

Question :

How would I for example extract 'just' the url for the picture (e.g the text url line. 'https://qoto.org/media/nDWr_rzPjQbyxsh6ikA' which will be different each time, but would have 'https://qoto.org/media'

running

cat output1.txt | grep "https://qoto.org/media"; >> toot.txt

appears to keep the "Text URL: " in place but does include the url.

Can anyone help please.  I am probably 90% of the way there with this.


Thanks

Paul

--
Paul Sutton, Cert ContSci (Open)
https://personaljournal.ca/paulsutton/

LibrePlanet 2021 - March 2021 - https://libreplanet.org/wiki/Main_Page

--
The Mailing List for the Devon & Cornwall LUG
https://mailman.dcglug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq