The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for the ‘bash’ Category

When you get an error 103 establishing an SFTP

Posted by jpluimers on 2025/12/10

A while ago I got an error 103 using both Beyond Compare. That did not whos the connection log or error reason, but WinSCP did: it mentioned unexpected output during the logon.

I got reminded that I had already solved this error before via [Wayback/Archive] SSH login works but SFTP login doesn’t – Server Fault (thanks [Wayback/Archive] qreon and [Wayback/Archive] Paulus):

Read the rest of this entry »

Posted in *nix, *nix-tools, bash, bash, Beyond Compare, Communications Development, Development, Internet protocol suite, Power User, Scripting, SFTP, Software Development, SSH, TCP, Windows, WinSCP | Leave a Comment »

bash alias to decode email Quoted-Printable stdin data

Posted by jpluimers on 2025/09/25

Perl isn’t my strength, so I was glad to find the below links that inspired me to add this bash function to my profile decoding Quote-Printable email data (for instance used by sendmail and postfix to store SMTP message files):

# https://superuser.com/questions/1452249/fix-revert-wrong-encoding-of-file
function sendmail-decode-quoted-printable-from-stdin() {
  perl -0777 -ne 'use MIME::QuotedPrint; print decode_qp($_)'
}

Read the rest of this entry »

Posted in *nix, *nix-tools, bash, bash, Development, Perl, Power User, Python, Scripting, sendmail, Software Development | Leave a Comment »

linux – Get final URL after curl is redirected – Stack Overflow (plus some Twitter scraping tricks)

Posted by jpluimers on 2025/08/06

Sometimes I need [Wayback/Archive] Redirect Checker | Check your Statuscode 301 vs 302 on the command-line, so cURL to the rescue: [Wayback/Archive] linux – Get final URL after curl is redirected – Stack Overflow. The relevant portions of answers and comments further below.

TL;DR:

Since I prefer verbose command-line arguments (you can find them at the [Wayback/Archive] curl – How To Use on-line man page) especially in scripts this HTTP GET request is what works with Twitter:

% curl --location --silent --output /dev/null --write-out "%{url_effective}\n" https://twitter.com/anyuser/status/20
https://x.com/anyuser/status/20

This failed (twitter dislikes HTTP HEAD requests):

% curl --head --location --silent --output /dev/null --write-out "%{url_effective}\n" https://twitter.com/anyuser/status/20
https://twitter.com/anyuser/status/20

Notes

Given so many of my scripts now run on zsh, I added the new-line because of command line – Why does a cURL request return a percent sign (%) with every request in ZSH? – Stack Overflow. You can strip that bit.

Note that these do not perform client side redirects, so they do not return the ultimate originating URL https://x.com/jack/status/20 (which was the first ever Tweet on what was back then called twttr) as Twitter on the client-side overwrites window.location.href with the final URL. Similar behaviour for getting the Twitter user handle of a Twitter user ID, more on Twitter tricks below.

Tweet by TweetID trick via [Wayback/Archive] Accessing a tweet using only its ID (and without the Twitter API) – Bram.us.

Further reading (thanks [Wayback/Archive] vise, [Wayback/Archive] Daniel Stenberg, [Wayback/Archive] Ivan, [Wayback/Archive] AndrewF, [Wayback/Archive] Roger Campanera, and [Wayback/Archive] Dave Baird):

Read the rest of this entry »

Posted in *nix, *nix-tools, bash, Batch-Files, Bookmarklet, Communications Development, Conference Topics, Conferences, CSS, cURL, Development, Event, HTTP, Internet protocol suite, JavaScript/ECMAScript, Power User, Scripting, SocialMedia, Software Development, TCP, Twitter, Web Browsers, Web Development | Tagged: | Leave a Comment »

command line – Why does a cURL request return a percent sign (%) with every request in ZSH? – Stack Overflow

Posted by jpluimers on 2025/07/31

I try to stay on the default shells of environments as much as possible, especially as that makes life easier when needing to work on an non-customised system.

Apple switched back from an ancient latest GPLv2 version 3.2 of bash (they regard newer GPLv3 as toxic to their revenue stream¹), introduced MIT-license based zsh and introduced a bash nag screen a few years ago forcing users to switch. Suppressing that message reliably is trickier than you might think².

After so many years of bash, I still stumble over things that zsh does differently: [Wayback/Archive] command line – Why does a cURL request return a percent sign (%) with every request in ZSH? – Stack Overflow (thanks [Wayback/Archive] Travis and [Wayback/Archive] zaTricky) is a “feature” with a simple workaround for cURL:

This is a zsh feature that prints a percent-and-newline after a command completes if that command does not already include a newline at the end of its output. If zsh did not do this, you would either not ever notice the fact that the command didn’t print a newline – or you’d see zsh’s command prompt not start on the margin and think it was a bug in zsh.

$ curl http://api.macvendors.com/0015c7   
Cisco Systems, Inc%     
$ curl -w '\n' http://api.macvendors.com/0015c7
Cisco Systems, Inc

Since the above example now writes a redirect messages (good bye HTTP, welcome HTTPS), and I very much dislike short command-line parameters, here is version with the long form of the [Wayback/Archive] curl -w or --write-out parameter :

Read the rest of this entry »

Posted in *nix, *nix-tools, Apple, bash, bash, Development, Mac OS X / OS X / MacOS, macOS 14 Sonoma, macOS 15 Sequoia, Power User, Scripting, Software Development, zsh | Leave a Comment »

“NAMED_CONF_INCLUDE_FILES” has been gone from /etc/sysconfig/named since OpenSuSE 15.4

Posted by jpluimers on 2025/04/28

In the past, I used to modify /etc/sysconfig/named and add entries to the NAMED_CONF_INCLUDE_FILES setting, then run /usr/share/bind/createNamedConfInclude
to generate /etc/named.conf.include.

As of OpenSuSE 15.4, /usr/share/bind/createNamedConfInclude has become an empty file and NAMED_CONF_INCLUDE_FILES got removed and NAMED_INITIALIZE_SCRIPTS introduced.

So now I changed my playbooks to manually generate /etc/named.conf.include and include it form /etc/sysconfig/named.

Since I hardly perform these new installations, it took a few years for me to find out about this change. Upgrading existing systems somehow kept the generated file and included it.

Related links with quotes as it was hard to find out what changed and how to work around and I wasn’t the only one bump into issues:

Read the rest of this entry »

Posted in *nix, *nix-tools, bash, bash, bind-named, Development, DNS, LEAP, Linux, openSuSE, Power User, Scripting, Software Development, SuSE Linux | Tagged: | Leave a Comment »

Weather info in plain text or JSON

Posted by jpluimers on 2025/03/06

Two sites that can help you out getting weather info on the console:

wttr.in

wttr.in is developed by [Wayback/Archive] Igor Chubin (@igor_chubin) / X and looks at the request header to figure out what kind of output it sends.

It supports various output formats, so on my TODO list is to see how they do their mapping: always an opportunity to learn (it’s based on Python and Go so I am curious what libraries they use as well).

From the documentation:

wttr.in currently supports five output formats:

  • ANSI for the terminal;
  • Plain-text for the terminal and scripts;
  • HTML for the browser;
  • PNG for the graphical viewers;
  • JSON for scripts and APIs;
  • Prometheus metrics for scripts and APIs.

The ANSI and HTML formats are selected based on the User-Agent string.

There are more parameters in the documentation on the main page of the repository and through this command:

curl wttr.in/:help

The idea is derived from [Wayback/Archive] GitHub – schachmat/wego: weather app for the terminal.

Oh: Igor has more repositories at [Wayback/Archive] chubin (Igor Chubin) · GitHub (including [Wayback/Archive] GitHub – chubin/cheat.sh: the only cheat sheet you need which is hosted at [Wayback/Archive] cheat.sh; I thought I had blogged about that before, but found it only in a draft note mentioning that I got it via [WaybackSave/Archive] Nicolas Krassas on X: “The only cheat sheet you need cheat.sh)

7timer

A 7 timer JSON usage example is at [Wayback/Archive] Get Weather from 7Timer! · GitHub

It has documentation at

Output formats can be chosen from HTML, PNG, XML and JSON.

Via

[Wayback/Archive] Hacker Public Radio – hpr4266 :: What’s the weather?
Lee writes a script to check what the weather is like ~ The Technology Community Podcast

HPR is a great podcast series!

--jeroen

Posted in *nix, *nix-tools, ash/dash, bash, bash, Development, Go (golang), JavaScript/ECMAScript, JSON, Power User, Python, Scripting, Software Development, Web Development, XML/XSD | Leave a Comment »

ShellCheck – shell script analysis tool

Posted by jpluimers on 2024/02/22

Cool: [Wayback] ShellCheck – shell script analysis tool

ShellCheck finds bugs in your shell scripts

It needs a shebang at the start of a script (like #!/usr/bin/env bash) to recognise the kind of shell, then does amazing analysis.

It is open source at [Wayback/Archive.is] koalaman/shellcheck: ShellCheck, a static analysis tool for shell scripts with excellent documentation including explaining screenshots like

It’s not just available on-line or on the command-line, but also integrates with many code editors (like [Wayback/Archive.is] ShellCheck – Visual Studio Marketplace: Integrates ShellCheck into VS Code, a linter for Shell scripts.) and CI/CD pipelines.

Via: [Wayback] bash – error conditional binary operator expected in compound branch – Unix & Linux Stack Exchange (thanks [Wayback] Cyrus!)

–jeroen

Posted in *nix, *nix-tools, ash/dash, ash/dash development, bash, bash, Development, Power User, Scripting, Software Development | Leave a Comment »

GitHub – kellyjonbrazil/jc: CLI tool and python library that converts the output of popular command-line tools and file-types to JSON or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.

Posted by jpluimers on 2023/10/17

I already knew about jq and jo (output: the echo for JSON), but not yet about jc for JSON.

Like jq is for querying (the sed for JSON), jc tries to be the universal parser of common command-line tools into JSON:

[Wayback/Archive] kellyjonbrazil/jc: CLI tool and python library that converts the output of popular command-line tools and file-types to JSON or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.

Via [Wayback/ArchiveKris on Twitter: ““Jc” verwandelt den Output von üblichen Linux Kommandozeilen Tools in JSON. “Jc” kann auch als Import in Python Programmen verwendet werden und mit subprocess kombiniert werden. Danke, ⁦@janwalzer⁩ und ⁦@the_mutax⁩ für den Tip. “

A few weeks later though, Kris discovered that command-line tools aren’t that portable in their output format: [Wayback/Archive] Kris on Twitter: “As much as I love the idea of @kellyjonbrazil’s jc, this is not a winnable game. sigh Probably still better than a self-cooked parser, but the slightest bit of extra makes it catch fire in multiple possible ways …”

Read the rest of this entry »

Posted in *nix, *nix-tools, bash, bash, Development, JavaScript/ECMAScript, jo, jq, JSON, man/manual pages, mankier, Power User, Python, Scripting, Software Development | Leave a Comment »

Some threadreaderapp URLs

Posted by jpluimers on 2023/09/14

For my link archive so I can better automate archiving Tweet threads using bookmarklets written in JavaScript:

The base will likely be this:

javascript:void(open(`https://archive.is/?run=1&url=${encodeURIComponent(document.location)}`))

which for now I have modified into this:

javascript:void(open(`https://threadreaderapp.com/search?q=${document.location}`))

It works perfectly fine without URL encoding and demonstrates the JavaScript backtick feature for template literals for which you can find documentation at [WayBack/Archive] Template literals – JavaScript | MDN.

Read the rest of this entry »

Posted in *nix, *nix-tools, bash, bash, Bookmarklet, Communications Development, cURL, Development, HTTP, https, Internet protocol suite, Power User, Scripting, Security, Software Development, TCP, Web Browsers | Leave a Comment »

Figuring out the threads for processes ran by python

Posted by jpluimers on 2023/08/17

A while ago I wrote about Figuring out the open network connections for processes ran by python, which explained the TL;DR:

pidof python | tr " " "\n" | xargs -r -n 1 lsof -i -a -e /run/user/1001/gvfs -p 

Now I needed thread information as well, so below two examples using ps and pstree. I won’t explain the pidof and xargs stuff here as that was already covered in the above blog-post and I found out that ps already has a built-in way to filter on process name.

The ps solution uses the H, -L or -T argument to show the threads:

Read the rest of this entry »

Posted in *nix, *nix-tools, bash, Development, lsof, Power User, ps, Scripting, Software Development | Leave a Comment »