writing.exchange is one of the many independent Mastodon servers you can use to participate in the fediverse.
A small, intentional community for poets, authors, and every kind of writer.

Administered by:

Server stats:

336
active users

#scripting

4 posts4 participants0 posts today

In less than 18 hours, including a solid 12 hours (at least) of downtime, I have gone from concept to 90% functional prototype of a creative rPi project, thanks to aus.social allowing quick and easy downloads, jq, an obscure CUPS driver project, and an intimate knowledge of scripting.

Feeling very accomplished.

Today I found that bash uses dynamic scoping, not lexical scoping. So if you have a

function inner() {
echo "$x"
}

it will go up the call stack to find the first x defined as

local x

in any caller and print it. Pity (add more swearwords here)🙁 . There is a reason why emacs lisp is being converted to lexical scoping despite having decades of dynamic binding history.

#bash #dynamicscoping #lexicalscoping #programming #scripting

stackoverflow.com/a/48166252/2

Stack OverflowUnderstanding lexical scoping - is Wikipedia correct?I've been trying to grok lexical scoping (I'm far from convinced by the use of the word lexical but that's another discussion) and I've looked at Wikipedia's entry. According to the fairly simple ...

So new infosec challenge with people asking LLMs to write small applications for simple tasks and then using them without checking what the script actually does.
I asked a coworker yesterday what language* the script he generated that way was written in. The answer was ‘French’ and that basically tells you all you need to know why ICT got a panic attack.

*it pulled in three JavaScript libraries from somewhere and luckily ran locally without phoning home.

I had to solve a problem where a PowerShell script would be distributed to clients that had to send mails. Putting email credentials in the script was not an option, so I put together a web-accessible API that allows me to send mail from a script without putting credentials at risk or relying on third-party mail libraries.
Sharing is caring, so here it is for you to self-host.
#php #api #sendmail #scripting #selfhosted #opensource #oss
github.com/soulflyman/CuckooPo

GitHubGitHub - soulflyman/CuckooPost: CuckooPost is a self-hosted token-based email sending service that offers secure mailing through SMTP or PHP's mail() and includes an admin interface for managing tokens.CuckooPost is a self-hosted token-based email sending service that offers secure mailing through SMTP or PHP's mail() and includes an admin interface for managing tokens. - soulflyman/CuckooPost

Functional logrotate for ~/.xsession-errors written in Bash. Say what you will about .xsession-errors, but it may be a bother to have to deal with when it's on the system. This script just adds /var/log/ style logrotation within the home folder so the versions are all next to one another. Make sure to set user folder correctly in the script if using in cron or it will parse ~ as root. Thanks for your help everyone! #Linux #Bash #Coding #Scripting #Code

Want to trigger some #bash action once a process is finished? Find the pid of the process with `ps` or `top` (1234 in this example) and then:

while ps 1234 ; do sleep 5 ; done ; git add . && git commit -m 'Updated dependencies.'

The commands after the `done;` will happen once the process finishes. Keep in mind that this will fire regardless of whether it finished successfully, but this is useful for triggering an action on an already long-running process.