Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: Ubuntu-Forum & Kubuntu-Forum | www.Ubuntu-Forum.de. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

1

15.07.2010, 13:21

Bash-Script zum Herunterladen von Eclipse

Hallo,

ich habe mir gedacht, es wäre vielleicht nicht schlecht ein Download-Script für Eclipse zu haben, welches einem den "Kontrollgang" auf eclipse.org erspart.
Im Repo von vielen Distributionen ist ja meist nicht die aktuellste Version von Eclipse :(

Ich bin auch schon soweit, dass ich von eclipse.org die Seite mit den Links zerfriemelt bekomme und mir daraus eine Liste basteln möchte, die ich dann in einer Schleife an wget übergebe.

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

# Links im WWW und Ziele auf der Platte
WEBLINK="http://www.eclipse.org/downloads/packages/"
TARGETDIR="/tmp/";
TARGETWINDOWS="/mnt/raid/software/windows/development/eclipse/"
TARGETLINUX="/mnt/raid/software/linux/development/eclipse/"
TARGETMAC="/mnt/raid/software/mac/development/eclipse/"
SPEEDLIMIT="250k";

# Seite holen, Eclipse-SDK rausfiltern, Seite zerfleddern, nach Dateiendung schauen, Linkliste erstellen -> Wget
wget $WEBLINK -O eclipse-site
cat eclipse-site | grep eclipse-SDK > eclipse-links
sed -n -e 's/\(^.*<a href="\)\([^"]*tar.gz|*zip\)\(".*$\)/\2/gp' eclipse-links > dllinks | sed -n -e 's%http://www.eclipse.org/downloads/download.php?file=%http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse%gp' dllinks > eclipsedllinks
cat eclipsedllinks | while read line; do wget -N $line --limit-rate=$SPEEDLIMIT --directory-prefix=$TARGETDIR; done;

# ueberbleibsel entfernen und dateien in nfs-verzeichnisse schmeissen
rm -f eclipse-site eclipse-links dllinks eclipsedllinks
mv /tmp/*win32* $TARGETWINDOWS
mv /tmp/*carbon* $TARGETMAC
mv /tmp/*cocoa* $TARGETMAC
mv /tmp/*linux* $TARGETLINUX


Es scheitert bei mir schon an der sed Zeile. Ich möchte versuchen, alles ab dem "<a href=" " rauszuholen, was mit .tar.gz oder .zip endet. Das soll dann in eine datei dllinks und in der möchte ich noch den Mirror umschreiben, damit das auch funktionierende Links werden.
Die Schleife funktioniert, wenn ich manuell etwas in eclipsedllinks reinschreibe :)

Kann mir vielleicht jemand mit der sed Zeile helfen?

Vielen Dank im Voraus,
Gruß huibuh

Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »huibuh« (15.07.2010, 17:17)


  • »floogy« ist männlich

Beiträge: 3 071

Registrierungsdatum: 10.03.2005

Derivat: Ubuntu

Architektur: 64-Bit PC

Desktop: GNOME 3.0

Andere Betriebssysteme: debian

  • Nachricht senden

2

15.07.2010, 15:05

Das klappt so nicht, da die downloads mit mirrors arbeiten.
Vielleicht nicht ganz elegant, extrahiert aber die Downloadlinks:

Quellcode

1
wget --spider $(wget "http://www.eclipse.org/downloads/packages/"  -O - 2>/dev/null| egrep '(^.*eclipse-SDK.*$)'|sed -e 's/\<a\ href\="/#/g' |awk -F# '{print $1"\n"$2"\n"$3"\n"$4}'|awk -F" '{print $1}'|awk -F"<" '{print $1}'|sed -e 's/http\:/\nhttp\:/g'|grep http|sed -E 's#http\:\/\/www\.eclipse\.org\/downloads\/download\.php\?file\=\/eclipse\/downloads\/#http\:\/\/download\.eclipse\.org\/eclipse\/downloads\/#g')


Deine sed-Zeile sollte so funktionieren:

Quellcode

1
wget "http://www.eclipse.org/downloads/packages/"  -O - 2>/dev/null|grep eclipse-SDK|sed -E 's/.*\<a\ href\=".*\/(.*gz|.*zip).*$/\1/g'


allerdings fehlen da einige 32bit Archive?

EDIT: Das liegt an Umbrüchen:

Quellcode

1
wget "http://www.eclipse.org/downloads/packages/"  -O - 2>/dev/null|grep eclipse-SDK|tr "\t" "\n"|sed -E 's/.*\<a\ href\=".*\/(.*.gz|.*.zip).*/\1/g'|grep eclipse

gibt folgendes aus:

Quellcode

1
2
3
4
5
6
7
eclipse-SDK-3.6-win32.zip
eclipse-SDK-3.6-win32-x86_64.zip
eclipse-SDK-3.6-macosx-carbon.tar.gz
eclipse-SDK-3.6-macosx-cocoa.tar.gz
eclipse-SDK-3.6-macosx-cocoa-x86_64.tar.gz
eclipse-SDK-3.6-linux-gtk.tar.gz
eclipse-SDK-3.6-linux-gtk-x86_64.tar.gz

Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »floogy« (15.07.2010, 16:16)


3

15.07.2010, 16:17

Hallo floogy,

danke für die Antwort. Das mit den Mirrors wollte ich ja durch die Ersetzung/Substitution (schön eingedeutscht) von:

Quellcode

1
sed -n -e 's%http://www.eclipse.org/downloads/download.php?file=%http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse%gp' dllinks > eclipsedllinks


machen. Die Zeile scheint auch zu funktionieren.

Edit: man bist Du schnell, hatte den selben Einfall :thumbup:

Gruß,
huibuh

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »huibuh« (15.07.2010, 17:18)


  • »floogy« ist männlich

Beiträge: 3 071

Registrierungsdatum: 10.03.2005

Derivat: Ubuntu

Architektur: 64-Bit PC

Desktop: GNOME 3.0

Andere Betriebssysteme: debian

  • Nachricht senden

4

15.07.2010, 16:37

So wird ein Schuh draus:

Quellcode

1
wget --spider $(wget "http://www.eclipse.org/downloads/packages/"  -O - 2>/dev/null|grep eclipse-SDK|tr "\t" "\n"|sed -E 's/.*\<a\ href\=".*\/(.*\/.*.gz|.*\/.*.zip).*/\1/g'|grep eclipse|sed -e 's/R\-/http\:\/\/ftp\-stud\.fht\-esslingen\.de\/pub\/Mirrors\/eclipse\/eclipse\/downloads\/drops\/R\-/g')


Wenn Du wget --spider noch hiermit ersetzt sollte es funktionieren:

Quellcode

1
wget -N  --limit-rate=$SPEEDLIMIT --directory-prefix=$TARGETDIR

außerdem "http://www.eclipse.org/downloads/packages/" mit $WEBLINK ersetzten.
zu

Quellcode

1
-O - 

das Minuszeichen hinter -O weist wget an den Inhalt der Datei auf der Standardausgabe auszugeben.

Wenn Du dann noch "http\:\/\/ftp\-stud\.fht\-esslingen\.de\/pub\/Mirrors\/eclipse\/eclipse\/downloads\/drops" als Variable einsetzt könnte man auch noch die Mirrors konfigurieren.

Das könnte dann so aussehen (Das funktioniert nun):

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

# Links im WWW und Ziele auf der Platte
WEBLINK="http://www.eclipse.org/downloads/packages/"
MIRROR="http\:\/\/ftp\-stud\.fht\-esslingen\.de\/pub\/Mirrors\/eclipse\/eclipse\/downloads\/drops" # Mirror 1
#MIRROR="http\:\/\/download\.eclipse\.org\/eclipse\/downloads\/drops" # Mirror 2
# Weitere mirrors, Sonderzeichen müssen für sed mit einem Backslash [\] maskiert werden.
#http://mirror.netcologne.de/eclipse//eclipse/downloads/drops
#http://d2u376ub0heus3.cloudfront.net/eclipse/downloads/drops #Amazon Web Services
#http://mirror.selfnet.de/eclipse/eclipse/downloads/drops
#http://sunsite.informatik.rwth-aachen.de/eclipse/downloads/drops

TARGETDIR="/tmp/";
# Bitte anpassen!
TARGETWINDOWS="/mnt/raid/software/windows/development/eclipse/"
TARGETLINUX="/mnt/raid/software/linux/development/eclipse/"
TARGETMAC="/mnt/raid/software/mac/development/eclipse/"
SPEEDLIMIT="250k";

WGETOPTIONS="--spider" #Test
#WGETOPTIONS="--version"
#WGETOPTIONS="-N  --limit-rate=$SPEEDLIMIT --directory-prefix=$TARGETDIR"  # Archive downloaden

function fetcheclipse() {
# Downloadseite auf STDOUT ausgeben
wget $WEBLINK  -O - 2>/dev/null |\

# Zeilen mit relevanten URLs extrahieren
grep eclipse-SDK |\

# Tabs in Zeilenumbrüche wandeln
tr "\t" "\n" |\

# Release/archive extrahieren 
sed -E 's/.*\<a\ href\=".*\/(.*\/.*.gz|.*\/.*.zip).*/\1/g' |\

#  URL-Filter
grep eclipse |\

# URL, je nach Mirror vervollständigen.
sed -e 's/R\-/'$MIRROR'\/R\-/g' 
}


wget $WGETOPTIONS  $(fetcheclipse)  # Archive downloaden


# dateien in Zielverzeichnisse verschieben
mv /tmp/*win32*zip $TARGETWINDOWS
mv /tmp/*carbon*gz $TARGETMAC
mv /tmp/*cocoa*gz $TARGETMAC
mv /tmp/*linux*gz $TARGETLINUX

Dieser Beitrag wurde bereits 10 mal editiert, zuletzt von »floogy« (15.07.2010, 18:38)


5

15.07.2010, 17:16

Hallo,

vielen Dank an floogy für seine Hilfe. Hier noch für die Copy-Paste-Faulen das lauffähige Script:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash

# title: eclipse downloader v2
# description: checks for new downloads on eclipse.org for the eclipse classic version
# 		if there are new files they will be downloaded. if not, it won't
# written by: huibuh

# links and directories
WEBLINK="http://www.eclipse.org/downloads/packages/"
TARGETDIR="/tmp/";
TARGETWINDOWS="/mnt/raid/software/windows/development/eclipse/"
TARGETLINUX="/mnt/raid/software/linux/development/eclipse/"
TARGETMAC="/mnt/raid/software/development/eclipse/"
SPEEDLIMIT="250k";

# get site
# grep for eclipse-SDK
# replace tabs with linebreaks
# extract zip and gz links
# prefix uni esslingen's mirror
# download the files

wget -N --limit-rate=$SPEEDLIMIT --directory-prefix=$TARGETDIR $(wget $WEBLINK  -O - 2>/dev/null|grep eclipse-SDK|tr "\t" "\n"|sed -E 's/.*\<a\ href\=".*\/(.*\/.*.gz|.*\/.*.zip).*/\1/g'|grep eclipse|sed -e 's/R\-/http\:\/\/ftp\-stud\.fht\-esslingen\.de\/pub\/Mirrors\/eclipse\/eclipse\/downloads\/drops\/R\-/g')

# after downloading move the files from tmp into the right folders
mv /tmp/*win32* $TARGETWINDOWS
mv /tmp/*carbon* $TARGETMAC
mv /tmp/*cocoa* $TARGETMAC
mv /tmp/*linux* $TARGETLINUX


Und im Endeffekt löppt das bis Eclipse.org wieder was an ihrer Seite ändert ;-)

Gruß,
huibuh

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »huibuh« (15.07.2010, 17:18)


  • »floogy« ist männlich

Beiträge: 3 071

Registrierungsdatum: 10.03.2005

Derivat: Ubuntu

Architektur: 64-Bit PC

Desktop: GNOME 3.0

Andere Betriebssysteme: debian

  • Nachricht senden

6

15.07.2010, 17:39

Meins läuft jetzt auch, ich musste das in eine Funktion packen, um es nicht als oneliner unübersichtlich zu halten.

Zeile 20 Spider auskommentieren und Zeile 22 aktivieren und es sollte downloaden statt nachschauen.

Das mit dem Timestamp (-N) soll wohl dafür sorgen, dass wget nur neuere Archive herunterläd. Das funktioniert aber nicht, wenn diese aus /tmp entfernt werden.

Dieser Beitrag wurde bereits 4 mal editiert, zuletzt von »floogy« (15.07.2010, 19:44)


7

19.07.2010, 13:06

Hallo floogy,

stimmt. aber wenn man aus dem mv ein cp macht, dann schon :)

Aber noch etwas anderes: auf älteren Hosts oder Hosts mit nicht brand neuen OS wie z.B. CentOS scheint das sed -E nicht zu funktionieren. Da kommt dann sowas:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
sed: invalid option -- E
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
  -i[SUFFIX], --in-place[=SUFFIX]
                 edit files in place (makes backup if extension supplied)
  -c, --copy
                 use copy instead of rename when shuffling files in -i mode
		 (avoids change of input file ownership)
  -l N, --line-length=N
                 specify the desired line-wrap length for the `l' command
  --posix
                 disable all GNU extensions.
  -r, --regexp-extended
                 use extended regular expressions in the script.
  -s, --separate
                 consider files as separate rather than as a single continuous
                 long stream.
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
      --help     display this help and exit
      --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

E-mail bug reports to: bonzini@gnu.org .
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
wget: missing URL
Usage: wget [OPTION]... [URL]...


Auf Fedora, Ubuntu und ArchLinux-Systemen funktioniert das... eine Abhilfe für ältere Systeme ist anstatt -E einfach -r -e zu benutzen :-)

Gruß,
huibuh