Useless Scripts/Programs

To contrast with the Useful scripts thread, this is for sharing your most pointless stuff.

I'll start:

This C program literally just allocates exactly 128 bytes of memory to write a random value to it. It then proceeds to only print where the number is located, but not the number itself, and it also frees said space right after, so you can't even have a chance at retrieving it.
I guess you could mess with the size parameter here to do some testing or make it write at a specific memory address, but other than that, it's really pointless.

C:
#include <stdio.h>
#include <stdlib.h>

int main() {
    long int *rand = malloc(128);

    *rand = random();

    printf("0x%x\n", rand);

    free(rand);

    return 0;
}

As for a script, here I have a Bash one that insults you or makes a joke according to the kind of signal you send to it, meaning it can "only" really be killed by SIGINT, which Bash itself reserves for getting killed when needed (there're more signals that i got too lazy to implement here, but you get the gist):

Bash:
#!/bin/bash

trap "echo Fuck you" SIGHUP
trap "echo No I won\'t!" SIGINT
trap "echo Nuh uh!" SIGQUIT
trap "echo Illegal my ass!" SIGILL
trap "echo More like SIGCRAP!" SIGTRAP
trap "echo You\'re the abortion here" SIGABRT
trap "echo Go to Hell with that bus!" SIGBUS
trap "echo How can this be floating-point if it\'s pointless?" SIGFPE
trap "echo Fuck User 1" SIGUSR1
trap "echo SEGMENTATION fault, not mine!" SIGSEGV
trap "echo Fuck User 2" SIGUSR2
trap "echo Go PIPE your ass instead!" SIGPIPE
trap "echo Wake the fuck up!" SIGALRM
trap "echo Terminal illness" SIGTERM
trap "echo STACK fault, not mine!" SIGSTKFLT
trap "echo What CHILD?" SIGCHLD
trap "echo More like SIGCUNT!" SIGCONT
trap "echo Make me!" SIGSTOP
trap "echo Deal with this." SIGTSTP
trap "echo Titty in" SIGTTIN
trap "echo Titty out" SIGTTOU
trap "echo I don\'t care about your data!" SIGURG
trap "echo You gave your CPU to me, now deal with it." SIGXCPU
trap "echo I don\'t care about limits!" SIGXFSZ
trap "echo Just 5 more minutes!" SIGVTALRM
trap "echo Eek! Don\'t \"profile\" me!" SIGPROF
trap "echo I don\'t care about your window···" SIGWINCH
trap "echo Cool, I don\'t care" SIGIO
trap "echo YOU are the failure here" SIGPWR
trap "echo System call? Never heard of her" SIGSYS

while true; do
    printf ""
done

So, what else would you guys add to this list? The more elegantly/complicatedly pointless the better! : )
 
just looked in our home directory and we have no idea where foo.c came from or why it contains this, but here you go:
C:
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
int
main(int argc, char *argv[])
{
    puts("h");
    return EXIT_SUCCESS;
}

stat -x foo.c says
Code:
Change: Sat Sep 17 20:55:17 2022
 Birth: Sat Sep 17 20:54:34 2022
 
Here is shortest almost useless program.

Code:
IEFBR14    CSECT
           XR        15,15            ZERO RETURN CODE
           BR        14               RETURN

What does it do? Let's translate this to C:

C:
int
main()
{
    return (0);
}

Pretty useless, eh?

In the UNIX world, it is useless. In the mainframe world, when using JCL , it's a NULL program that does nothing so that one can use JCL to dispose of datasets (files in UNIX parlance). IEFBR14 is a real thing.
 
Long ago there was a TSOshell. It is as bad as it sounds. Ctrl-C called a function maybe called tsosleep which was something like sleep (rand (++number)) except it may have turned the interrupt back on just to add to the delay. It understood redirection syntax, pipes and background tasks but simply refused to do it with an error and a call to tso_sleep. It may have converted all output or input to all caps for good measure. Its core was one of the very early shells and due to early at&t copyright issues, wasn't widely spread around.
 
we have no idea where foo.c came from or why it contains this
maybe a test program?

a NULL program that does nothing so that one can use JCL to dispose of datasets
i guess it's useless depending on where you apply it then heh, also that's a weird syntax, is it some obscure form of Assembly
 
First... to my defense (well, sorta... :-/) this happened in the weekend and I had a few drinks? (uh oh....).

So... PostgreSQL isn't just a database server to me, it's a way of life when it comes to storing/processing (bulk?) data from the command line. I'm one of those nerdy admins who also insists that local users should have their personal and easily used (peer access method FTW!) database as well. I mean... why bother with tricky to use datafiles, eh? Anyway, I recently upgraded the version to 18 and much to my pleasure the devs are becoming more "pushy" to move away from MD5 for password hashing, and instead suggest that you use SCRAM-SHA-256 as replacement. Yay!

I had just set up a backup server (for replication/standby) and wanted to do some quick experimentation. For some dumb reason I was convinced that I had to provide hashed passwords, and uh oh... OpenSSL (= my defacto crypto toolkit) can't handle SCRAM! At least not at the time of this story. Now what?!

Well, then I remembered that I've been studying Python for quite a while now, surely I would be able to build some kind of solution myself?

Python:
import hmac, os
from hashlib import pbkdf2_hmac, sha256
from base64 import standard_b64encode

def mkpasswd(password):
        salt = os.urandom(16)
        iter = 4096

        dk = pbkdf2_hmac('sha256', password.encode(), salt, iter, 32)

        clnt_key = hmac.digest(dk, b'Client key', 'sha256')
        intm_key = sha256(clnt_key).digest()
        srv_key = hmac.digest(dk, b'Server key', 'sha256')

        return f"SCRAM-SHA-256${iter}:{standard_b64encode(salt).decode()}${standard_b64encode(intm_key).decode()}:{standard_b64encode(srv_key).decode()}"

def input_pwd() -> str:
        return input("Geef password? => ")


print(mkpasswd(input_pwd()))

Now, I suppose this script isn't completely useless because it actually does something (sorta), but... soon my friend had finished her movie and came over. When she asked me what this was all about she also quickly reminded me of something by asking: "But didn't you ask me to just type out my password last week when you set up my database account?" 😶

Of course this script did end up being useless because I tried this with PSQL and rest assured: it no workie ;)
 
I suppose it's some humour. If it's not, it's a non-sense linux bashing. We don't need this.
It is. *sigh* I thought the code block part would have made that clear and/or brought a funny mental visual to the reader. Since humor is not needed, consider humor stored.
 
maybe a test program?

Consider a job step that created a file for a subsequent step or a step that deleted a file when the previous step returned a non-zero return code. The step still had to run a program in order to let the system handle file disposition in those edge cases.

It's a little more complicated than that but that's what it was used for.

One would never use it interactively from a terminal though.

i guess it's useless depending on where you apply it then heh, also that's a weird syntax, is it some obscure form of Assembly
The JCL interpreter, also in the kernel, may have borrowed from an assembler at the time. I think the format was used because early versions of OS (the predecessor of MVS and subsequently zOS today) ran on machines as small as 64KB. Small machines were a thing back then.

When I started working there were six mainframes in town. The total RAM installed on all six was less than 3MB, total, across the city. The telephone company had two mainframes, each with 1MB. An oil company and the university each had one with 512KB. And a couple of other shops ran IBM mainframes, one with 96KB and the last one, I never knew how much RAM it had, except that it was smaller than the telephone company's and university's computers. RAM was not plentiful then. The O/S had to be small.
 
i think we made it to demonstrate objdump to someone.
yeah that makes sense too

Consider a job step that created a file for a subsequent step or a step that deleted a file when the previous step returned a non-zero return code. The step still had to run a program in order to let the system handle file disposition in those edge cases.

It's a little more complicated than that but that's what it was used for.

One would never use it interactively from a terminal though.
fair enough, so that's where it becomes useless

The JCL interpreter, also in the kernel, may have borrowed from an assembler at the time. I think the format was used because early versions of OS (the predecessor of MVS and subsequently zOS today) ran on machines as small as 64KB. Small machines were a thing back then.
figures, by that ALL CAPS syntax i could also guess it was ancient

When I started working there were six mainframes in town. The total RAM installed on all six was less than 3MB, total, across the city. The telephone company had two mainframes, each with 1MB. An oil company and the university each had one with 512KB. And a couple of other shops ran IBM mainframes, one with 96KB and the last one, I never knew how much RAM it had, except that it was smaller than the telephone company's and university's computers. RAM was not plentiful then. The O/S had to be small.
i guess it was still good 'cos developers had to optimize their code, unlike nowadays where even Discord is a RAM hog and they try to fix it in the most regneck way imaginable
 
This script keeps the amount of /dev/ada* devices on a computer visible from far away,
Code:
#!/usr/local/bin/bash

while [ : ]
do
  clear
  (ls /dev/ada? /dev/ada?? 2>/dev/null | sort -V ) | while read l
  do
    echo "$l"
  done
  figlet "$(ls /dev/ada? /dev/ada?? 2>/dev/null | wc -l)"
  sleep .5
  read -n1 -t.1
  [ $? -eq 0 ] && exit 0
done
 
heh i guess if you implemented showing the amount of free/used space it'd be a little more useful for monitoring storage, could then also be expanded to include computers from a network
 
heh i guess if you implemented showing the amount of free/used space it'd be a little more useful for monitoring storage, could then also be expanded to include computers from a network
I'm annoyed by the duplicate ls execution for no reason. That had to be put in a var first. 😆
 
This script keeps the amount of /dev/ada* devices on a computer visible from far away,
Code:
#!/usr/local/bin/bash

while [ : ]
do
  clear
  (ls /dev/ada? /dev/ada?? 2>/dev/null | sort -V ) | while read l
  do
    echo "$l"
  done
  figlet "$(ls /dev/ada? /dev/ada?? 2>/dev/null | wc -l)"
  sleep .5
  read -n1 -t.1
  [ $? -eq 0 ] && exit 0
done
while sleep 0.5; do clear; geom disk status -s | wc -l | figlet; done
if you need to limit it to ada, stick a grep before the wc.
 
Back
Top