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,404 other followers

Archive for the ‘Scripting’ Category

bash: generating random passwords on Mac OS X / MacOS or what Apple calls their operating system by now

Posted by jpluimers on 2018/08/14

After some fiddling, I put this function in ~/bash_profile on my MacBook:

# pass # digits as first argument; defaults to 20
generate_password() {
  local l=$1
  [ "$l" == "" ] && l=20
  env LC_CTYPE=C LC_ALL=C tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs

The fiddling was working around this error:

tr: Illegal byte sequence

The cause is that Mac OS is not Linux, where tr happily accepts any byte sequence from /dev/urandom: it requires the C locale.

Originally, I started with the below function from [WayBackTop 20 OpenSSH Server Best Security Practices – nixCraft (thanks +Joe C Hecht) which I undid from mixed tab/spaces:

genpasswd() {
  local l=$1
  [ "$l" == "" ] && l=20
  tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs

Via: [WayBackJoe C. Hecht – Google+ who mentions:

I might add that if you do move the SSH port, try to keep it in within the first 1024 ports for a tad bit more protection on some systems.

Background reading on Apple hating binary input:

Background reading on the language setting:


Posted in Software Development, Development, Scripting, bash | 2 Comments »

windows – How to list all files in directory/subdirectory without path name CMD? – Stack Overflow

Posted by jpluimers on 2018/07/30

I needed all .dproj files in all subdirectories, but only their filenames without any directory names.

With directory names, this is easy:

dir /s /b *.dproj

The answers at [WayBack] windows – How to list all files in directory/subdirectory without path name CMD? – Stack Overflow give the below kind of output.

[WayBack] forfiles embeds all filenames within quotes:

forfiles /m *.dproj /s


A more convoluted [WayBack] for loop gives them without quotes where n stands for name and x for extension including .:

for /r %a in (*.dproj) do @echo %~nxa


Posted in Batch-Files, CommandLine, Development, Power User, Scripting, Software Development, Windows | Leave a Comment »

Just I in case I need to port to OpenSuSE properly

Posted by jpluimers on 2018/07/24

I came across a nice tool that combines httpd.conf files:

python /etc/apache2/httpd.conf /tmp/apache2.combined.conf

In case I ever need to fully port it to OpenSuSE, I’ve put it in the gist below.

For now it works fine on OpenSuSE when used with the above command. I might make the default depend on the kind of nx it runs on.



Read the rest of this entry »

Posted in *nix, *nix-tools, Apache2, Development, Linux, openSuSE, Power User, Python, Scripting, Software Development, SuSE Linux | Leave a Comment »

PowerShell on Mac OS X and other non-Windows systems

Posted by jpluimers on 2018/07/17

I wasn’t expecting it to be so easy to install PowerShell on Mac OS X:

brew install Caskroom/cask/powershell

In the background it executes this script: which indirectly goes through the URL template{version}/powershell-#{version}.pkg.

On other non-Windows systems, you have to go through GitHub yourself: The PowerShell team at Microsoft has many more repositories including the Win32-OpenSSH port which you can find through

At the time of writing, PowerShell was available for these platforms:

Platform Downloads How to Install
Windows 10 / Server 2016 (x64) .msi Instructions
Windows 8.1 / Server 2012 R2 (x64) .msi Instructions
Windows 7 (x64) .msi Instructions
Windows 7 (x86) .msi Instructions
Ubuntu 16.04 .deb Instructions
Ubuntu 14.04 .deb Instructions
CentOS 7 .rpm Instructions
OpenSUSE 42.1 .rpm Instructions
Arch Linux Instructions
Many Linux distributions .AppImage Instructions
macOS 10.11 .pkg Instructions
Docker Instructions

The first version I installed on Mac OS X was this: ==> Downloading

By now I really hope it is out of Alpha state.



Posted in *nix, Apple, CommandLine, Development, iMac, Linux, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, openSuSE, Power User, PowerShell, PowerShell, Scripting, Software Development, SuSE Linux, Ubuntu | Leave a Comment »

Mad With PowerShell

Posted by jpluimers on 2018/06/25

Cool blog:

[WayBackMad With PowerShell Tim Curwick’s PowerShell blog, tips and tricks, tools and techniques, explanations and explorations

via: [WayBack] Mad With PowerShell – Excellent blog by +Tim Curwick about the use and abuse of PowerShell, and brimming with good examples and clues. – Lars Fosdal – Google+



Posted in CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »

%d bloggers like this: