Last year I wrote two shell scripts, a chatting program to chat with other logged in users on different terminals (ttys), and a program that makes .deb packages for Debian based systems.

Cli-Chat (Part 1: The main program): http://cemetech.pastebin.com/nQeCgGBi
Cli-Chat (Part 2: Clears the chat logs): http://cemetech.pastebin.com/TXajEFCh
deb-make: http://cemetech.pastebin.com/th8yGWWt
You can run these by downloading them and executing chmod +x <name of script here>. The first script (Cli-Chat) is buggy, so don't execute it.

Edit: It seems that Pastebin is doing something weird to deb-make, so I will just post it here:

Code:

#!/bin/bash
touch debian.control1
touch debian.control2
touch debian.control3
while [ "$input" != "" ]; do
echo "Enter file path to be added to deb archive"

read input
dir=`dirname $input`
echo $input $dir
mkdir -p $HOME/build-deb/$name$dir > /dev/null
cp  $input /home/`whoami`/build-deb/$name$input > /dev/null
done
mkdir `echo $name`
cd `echo $name`
while [ "A" == "A" ]; do
clear
debian_control
pwd
case $choice in
    1) echo "Source"
    read source
    echo "Source: $source" > debian.control
    ;;
    2) echo "Section"
    read section
    echo "Section: $section" > debian.control
    ;;   
    3) echo "Priority"
    echo "Choose from Required, Important, Standard, Optional, Extra"
    read priority
    echo "Priority: $priority" > debian.control
    ;;   
    4) echo "Maintainer"
    read maintainer
    echo "Maintainer: $maintainer" > debian.control
    ;;   
    5) echo "Standards Version"
    read standards-version
    echo "Standards-version: $standards-version" > debian.control
    ;;   
    6) echo "Build Depends"
    echo "Packages required to be used by build-essential"
    read build-depends
    echo "Build-Depends: $build-depends" > debian.control
    ;;
    7) echo "Homepage"
    read homepage
    echo "Homepage: $homepage" > debian.control
    ;;
    8) echo "Architecture"
    echo "Current architecture is "`arch`
    echo "but use i386 or something else like that."   
    read arch
    echo "Architecture: $arch" > debian.control
    ;;
    9) echo "Depends"
    read depends
    echo "Depends: $depends" > debian.control
    ;;
    10) echo "Recommends"
    read rec
    echo "Recommends: $rec" > debian.control
    ;;
    11) echo "Suggests"
    read sug
    echo "Suggests: $sug" > debian.control
    ;;
    12) echo "Conflicts"
    read con
    echo "Conflicts: $con" > debian.control
    ;;
    13) echo "Description"
    read desc
    echo -e "Description: $desc" > debian.control
    ;;   
    14) builddeb
    ;;
    15 ) builddeb
    ;;   
esac
cat debian.control1 debian.control > debian.control3
cat debian.control3 > debian.control1
echo "" > debian.control3
done
Cool stuff, Souvik; thanks for sharing your scripts. Smile I'll try to find some fun scripts of mine to share. Ooooh, how about this one, which is part of SysMon 1.0?


Code:
#!/bin/bash

MNAME="simms4"
MHASH="30e514e0292f96eb7b8e2825e96749e3"

TEMPROW=`sensors | grep "temp1" | awk '{split($0,array," ")} END{print array[2]}' | sed -e 's/[^0-9.]//ig'`
MEMTOTAL=0
MEMFREE=0

while read line; do
        if `echo $line | grep -q "MemTotal"` ; then
                MEMTOTAL=`echo $line | awk '{split($0,array," ")} END{print array[2]}' | sed -e 's/[^0-9.]//ig'`;
        elif `echo $line | grep -q "MemFree"` ; then
                MEMFREE=`echo $line | awk '{split($0,array," ")} END{print array[2]}' | sed -e 's/[^0-9.]//ig'`;
        fi
done < /proc/meminfo

UPTIME=`uptime | sed -e 's/&//ig'`
wget -t 1 -O verifyresult.log `echo "http://[url here]/checkin.php?name=$MNAME&md5=$MHASH&temp=$TEMPROW&memtotal=$MEMTOTAL&memfree=$MEMFREE&uptime=$UPTIME" | sed -e 's/\s/\+/ig'` >>/var/scripts/errorz.txt
rm verifyresult.log errorz.txt
Very nice, but why do you define MHASH if it is supposed to be a md5sum?
souvik1997 wrote:
Very nice, but why do you define MHASH if it is supposed to be a md5sum?
Because it's a static verifier of the node to the server (not the best security, but meh). I didn't want to waste the time on each execution re-generating the hash.
Here's a quick one of mine, designed to extract zip archives and convert any contents into a flat cbz file.

Code:
#!/bin/bash
if [ $# -ne 1 ]
then
    echo "Usage: $0 infile.zip"
    exit 1
fi

TDIR="$(mktemp -d)"
ARCHIVENAME=`basename $1 .zip`

echo "Input archive: $1"
echo "Basename: $ARCHIVNAME"
echo "Tempdir: $TDIR"

unzip $1 -d $TDIR
pushd $TDIR
for d in */
do
    cd $d
    zip -r ../$ARCHIVENAME.cbz *.{jpg,png}
    cd ..
    rm -rf $d
done
popd
mv $TDIR/$ARCHIVENAME.cbz ./
rm -rf $TDIR
Excellent, Tari; thanks for sharing. Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement