Commands tagged scripting (2)

  • This function will encrypt a bash script and will only execute it after providing the passphrase. Requires mcrypt to be installed on the system. cat hello #!/bin/bash case "$1" in ""|-h) echo "This is the fantastic Hello World. Try this:" $(basename $0) "[entity]" ;; moon) echo Good night. ;; sun) echo Good morning. ;; world) echo "Hello, world!" ;; *) echo Hi, $@. ;; esac scrypt hello Enter the passphrase (maximum of 512 characters) Please use a combination of upper and lower case letters and numbers. Enter passphrase: Enter passphrase: Stdin was encrypted. cat hello.scrypt . <(echo "$(/usr/bin/tail -n+2 $0|base64 -d|mcrypt -dq)");exit; AG0DQHJpam5kYWVsLTEyOAAgAGNiYwBtY3J5cHQtc2hhMQAV34412aaE8sRzQPQzi09YaNQPedBz aGExAARvB6A/HYValW4txoCFmrlp57lmvhKBbM4p+OUiZcCxr6Y+Mm7ogg3Y14pHi0CrfT70Tubq 9g8/kNJrQr7W/ogHpVuOOdD0YfuRatrV7W2+OlNQ63KX780g4qTHrTqNnyLp8sF5RQ7GwxyZ0Oti kROtVIU4g4+QAtn/k/e7h7yt4404VF1zzCYRSw20wmJz1o/Z0XO7E/DFBr5Bau7bWjnF7CRVtims HGrDwv1miTtAcyB9PknymDxhSyjDUdNhqXGBIioUgqjX1CKgedtO0hQp050MiQd3I6HacpSrVUIW kuuS+BtMrxHDy+48Mh1hidV5JQFP7LP5k+yAVLpeHd2m2eIT1rjVE/Bp2cQVkpODzXcWQDUAswUd vulvj/kWDQ== ./hello This is the fantastic Hello World. Try this: hello [entity] ./hello.scrypt Enter passphrase: This is the fantastic Hello World. Try this: hello.scrypt [entity] ./hello world Hello, world! ./hello.scrypt world Enter passphrase: Hello, world! Show Sample Output

    scrypt(){ [ -n "$1" ]&&{ echo '. <(echo "$(tail -n+2 $0|base64 -d|mcrypt -dq)"); exit;'>$1.scrypt;cat $1|mcrypt|base64 >>$1.scrypt;chmod +x $1.scrypt;};}
    rodolfoap · 2017-06-14 16:27:20 2
  • use it to add a random boolean switch to your script Show Sample Output

    echo $[RANDOM % 2]
    anapsix · 2013-05-25 19:15:57 3

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Get your X11 screen mode

Rename all files which contain the sub-string 'foo', replacing it with 'bar'
Would this command line achieve the desired function? My CLI knowledge is not great so this could certainly be wrong. It is merely a suggestion for more experienced uses to critique. Best wishes roly :-)

Number of open connections per ip.
Here is a command line to run on your server if you think your server is under attack. It prints our a list of open connections to your server and sorts them by amount. BSD Version: $ netstat -na |awk '{print $5}' |cut -d "." -f1,2,3,4 |sort |uniq -c |sort -nr

Open a manpage in the default (graphical) web browser
An easy alias for opening a manpage, nicely HTML formatted, in your set internet browser. If you get a "command exited with status 3" error you need to install groff.

Set Time Zone in Ubuntu
Reconfigures time zone in Ubuntu, which I cannot figure out how to do through the GUI. Worked like a charm to set my time zone to CEST from EDT.

MoscowML with editable input-line and history
Works also with SML/NJ and other interpreters or tools with interactive environments.

AWS Route53 hosted zone export
Frustrated with the manual domain migration process AWS has, I unsuccessfully tried to install cli53, route53-transfer. I instead wrote this oneliner to ease the export (which is not supported via the AWS console ATM). The output can be easily pasted into the "Import Hosted Zone" dialog in Route53. SOA/NS records are excluded since they cannot be automatically imported.

Save man pages to pdf

Create a new file

ping with timestamp

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: