Posts

Showing posts with the label shell

Simple shell ("sh") database.

Image
From the Rosetta Code --------------------------------- $ sdb create CDs Create DB `CDs' $ sdb add CDs Bookends $ sdb prop CDs Bookends artists "Simon & Garfunkel" $ sdb add CDs "Ode to joy" $ sdb prop CDs "Ode to joy" artist "Beethoven" $ sdb tag CDs Bookends rock folk # I'm not sure about this $ sdb tag CDs "Ode to joy" classical $ sdb show CDs Bookends Description:   artists: Simon & Garfunkel   Tags: folk rock $ sdb prop CDs "Ode to joy" Description "Sym. No. 9" $ sdb show CDs "Ode to joy" Description: Sym. No. 9   artist: Beethoven   Tags: classical $ sdb list-all CDs Tag: classical Ode to joy   Tag: folk Bookends   Tag: rock Bookends   $ sdb drop CDs Delete DB `CDs' $   --------------------   #!/bin/sh   db_create ( ) { mkdir . / "$1" && mkdir "./$1/.tag" && echo "Create DB \ `$1'...

File listing into an html file.

Image
Just downloaded a bunch of PDF files and I wanted to put them on the server so they could be accessed easily. Since the pdf file list was over 200 items, did not want to go edit every line in the file manually from Your-personal-intranet-Part-2.pdf to <a href="Your-personal-intranet-Part-2.pdf">Your-personal-intranet-Part-2</a><br /> What to do? First was to make a list of the files. $ ls *.pdf > pdflist The you get: ... ... Yagi-foil-HDTV-antenna.pdf Yet-another-amplified-acoustical-guitar.pdf Yet-another-cheese-making-episode.pdf Yet-another-continuity-tester.pdf Yet-another-dtv-antenna.pdf Yet-another-simple-portable-disposable-barbecue-.pdf Yet-another-usb-coolerwarmer.pdf Yet-another-usb-lamp.pdf Your-first-Android-Application.pdf Your-personal-intranet-Part-1.pdf Your-personal-intranet-Part-2.pdf First was to make a list of the files. But then you may not want the pdf extension as part of the descriptions. So now to ...

Shell shock attacker?

Image

Server script.

Image
Wrote this script a while back to use the server to get information for me. Here is a newer incarnation of that same script. #!/bin/sh echo “Content-type: text/html\n” # read in our parameters CMD=`echo “$QUERY_STRING” | sed -n ‘s/^.*cmd=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”` FOLDER1=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder1=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER2=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder2=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER3=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder3=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER4=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder4=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER5=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder5=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER6=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder6=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER7=`echo “$QUERY...

Server script.

Image
Wrote this script a while back to use the server to get information for me. Here is a newer incarnation of that same script. #!/bin/sh echo “Content-type: text/html\n” # read in our parameters CMD=`echo “$QUERY_STRING” | sed -n ‘s/^.*cmd=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”` FOLDER1=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder1=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER2=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder2=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER3=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder3=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER4=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder4=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER5=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder5=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER6=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder6=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”` FOLDER7=`echo “$QUERY...

Ssh!!

One of the things most people hate to do is to type in passwords. Not only could someone be looking over your shoulder, but also the password gets sent where it can be easily monitored. There has to be a better way. A method very much used on 'nix systems (including OS/X) is called the 'secure shell' (ssh for short). You can actually use it on Microsoft systems also, but it requires more than usual extra setup. More about setting up here: ( http://www.instructables.com/id/Linux-setup-for-SSH-password-less-login/ ). $ ssh typo1 password: _ Anyway, if you are setting up a new system and or recovering from a hard disk crash, setting up the ssh keys to all the servers or systems you log into can be a lot of fun. There had to be a way of automating this process.  The process is usually just three steps. Copy your key to the new server, adding the key to the authorized_key files, and then lastly removing the copied key if need be. So let's make a batch file to take care ...