Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Shell Scripts
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
xmoy
Tux's lil' helper
Tux's lil' helper


Joined: 03 Aug 2004
Posts: 108
Location: .ch

PostPosted: Tue Aug 03, 2004 10:06 pm    Post subject: Shell Scripts Reply with quote

Hallo

Ich hab mir mal gedacht, ein Thread für diverse mehr oder weniger nützliche Shell Scripts wäre doch was tolles.
Nachfolgend mal zwei Beispiele von mir (aufs kommentieren habe ich aus Faulheit verzichtet ;) )

md5check.sh
Zwei Dateien via md5sum vergleichen.
usage: md5check.sh <filename1> <filename2>

Code:
#!/bin/bash

err_helpmsg="Usage: md5check.sh <filename1> <filename2>";
err_notvalid="does not exist or is not a file";

if test "$1" = ""; then echo $err_helpmsg; exit; fi;
if test "$2" = ""; then echo $err_helpmsg; exit; fi;

file1=$1;
file2=$2;

if ! test -f "$file1"; then
    echo "$file1 $err_notvalid";
    exit;
fi;
if ! test -f "$file2"; then
    echo "$file2 $err_notvalid";
    exit;
fi;

if test "`md5sum $file1 | awk '{print $1}'`" = "`md5sum $file2 | awk '{print $1}'`"; then
    echo "$file1 == $file2";
else
    echo "$file1 != $file2";
fi;

exit;




newJavaProject.sh
Erstellt einen neuen Ordner der Sample Java Sourcecode und Scripts zum compilieren und javadoc erstellen enthält
usage: newJavaProject.sh <projectname>

Code:
#!/bin/bash

if test "$1" = ""; then
    echo "!!  No projectname given";
    exit;
fi;

projectname=$1;

echo "    Trying to create directory ./$projectname";
if test -d "./$projectname"; then
    echo "!!  Directory ./$projectname already exists. (Re)move it and try again";
    exit;
else
    mkdir ./$projectname;
    echo "    Directory ./$projectname created";
fi;

echo "    Creating directory ./$projectname/bin";
mkdir ./$projectname/bin;
echo "    Directory ./$projectname/bin created";

echo "    Creating directory ./$projectname/doc";
mkdir ./$projectname/doc;
echo "    Directory ./$projectname/doc created";

echo "    Creating directory ./$projectname/src";
mkdir ./$projectname/src;
echo "    Directory ./$projectname/src created";

echo "    Creating example source file";
echo "/**"$'\n'"Description of your program $1"$'\n'"@author $USER"$'\n'"*/"$'\n\n'"public class $1 {"$'\n'"    public static void main(String[] args) {"$'\n'"    }"$'\n'"}" > ./$projectname/src/$projectname.java;
echo "    Source file ./$projectname/src/$projectname.java created";

echo "    Creating compile script";
echo "#!/bin/bash"$'\n'"javac -d ./bin ./src/*.java;"$'\n'"cd ./bin;"$'\n'"java $projectname;"$'\n'"cd ..;" > ./$projectname/$projectname.sh
chmod u+x ./$projectname/$projectname.sh;
echo "    Compilation script ./$projectname/$projectname.sh created";

echo "    Creating javadoc script";
echo "#!/bin/bash"$'\n'"javadoc -d ./doc/ ./src/*.java;" > ./$projectname/$projectname_doc.sh
chmod u+x ./$projectname/$projectname_doc.sh;
echo "    Javadoc script ./$projectname/$projectname_doc.sh created";

echo "    That's it, bye!";
exit;



Hoffe der Thread ist nicht zu sehr OT und ihr findet die Idee einigermassen akzeptabel. Vielleicht findet ja hier einmal der eine oder andere ein Script das er/sie brauchen kann.

Gruss
jonathan
_________________
:wq
Back to top
View user's profile Send private message
tm130
Tux's lil' helper
Tux's lil' helper


Joined: 28 Jul 2004
Posts: 110
Location: Indianapolis, IN, USA

PostPosted: Wed Aug 04, 2004 5:32 am    Post subject: Reply with quote

Pruefen von md5-Summen in einem script?

Code:
md5sum -c foo.md5
Back to top
View user's profile Send private message
xmoy
Tux's lil' helper
Tux's lil' helper


Joined: 03 Aug 2004
Posts: 108
Location: .ch

PostPosted: Wed Aug 04, 2004 7:05 am    Post subject: Reply with quote

Naja halt 2 Files miteinander vergleichen :wink:
_________________
:wq
Back to top
View user's profile Send private message
_hephaistos_
Advocate
Advocate


Joined: 07 Apr 2004
Posts: 2694
Location: salzburg, austria

PostPosted: Wed Aug 04, 2004 7:14 am    Post subject: Reply with quote

hi,

wie wärs, das ganze gleich mit einem array zu machen?
dh: man kann ./md5check.sh <file1> <file2> .... <fileN> angeben....?

ciao 8)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
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