Hilfe beim SCRIPT


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Hilfe beim SCRIPT
# 1  
Old 06-02-2010
Hilfe beim SCRIPT

Hallo,

unter Suse Linux 11.2 / Kubuntu 10.04 habe ich mir ein Service-Menü angelegt.
Bis auf das Nachfolgende funktioniert alles bestens.

Bisher habe ich auf der Konsole mit dem Programm pdftk Anhänge an ein Pdf-File erzeugt.

Der Code lautete
Code:
pdftk beispiel.pdf attach_files Anlage1.pdf Anlage2.pdf Anlage3.pdf output beispiel_mit_anhang.pdf

Das ganze habe ich nun in ein script gepackt ( oder zumindest versucht )

Code:
#!/bin/sh
# PDF Tool Sammlung zum Einbinden in KDE Service Menüs

RETURN=""

#
# Prüfen, dass mindestens ein Argument übergeben wurde
#
if [ $# -lt 1 ] ; then
  echo "Bitte das Script nicht direkt aufrufen." > /dev/stderr
  exit 1
fi

#
# Fallunterscheidungen (anhand des ersten Parameters)
#
case "$1" in
    pdftk-attach-files)    # Usage: ./pdftk-tools.sh pdftk-attach-files <input.pdf>
        # Prüfe Parameteranzahl
        if [ $# -ne 2 ] ; then exit ; fi
        
        # Hole Benutzereingaben
        INPUT="$2"
        ATTACHMENTS=`kdialog --title "Anhängen auswählen" --multiple --getopenfilename ~/ "*.pdf"`
        if [ $? -ne 0 ] ; then exit ; fi # Abbrechen, falls der Dialog einfach geschlossen wurde (--> kdialog gibt Returncode 1 zurück)
        OUTPUT="$INPUT.attachments.pdf"
        
        # Starte pdftk
        RETURN=`pdftk "$INPUT" attach_files "$ATTACHMENTS" output "$OUTPUT" 2>&1`
    ;;
    
    pdftk-bla)
        # irgendwas anders ...
    ;;
esac

#
# Fehlermeldung ausgeben, wenn das letzte ausgeführte Kommando nicht fehlerfrei ausgeführt wurde
#
if [ $? -ne 0 ] ; then
    kdialog --title "Fehler" --error "$RETURN"
fi

Wenn ich im Konqueror oder im Dolphin eine Pdf-Datei mit der rechten Maustaste markiere und das script starte, öffnet sich ein
Fenster, indem ich auf der Festplatte die Dateien markieren kann, die ich als Anhang an das Pdf File haben möchte.
Anschließend wird eine Datei mit dem Namen xxx.attachments.pdf erzeugt. Leider hat diese Datei keine Anhänge. Woran kann das liegen?


mfg
Hannes
# 2  
Old 06-02-2010
Hello.

Per our forum rules, all posts must be in English.

We do provide translation services for posts from English to a number of languages as a benefit to users. However, posts must be in English.

Please repost in English.

Thank you for your cooperation.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

5. OS X (Apple)

OS 10 lässt sich nicht mehr installieren...ubuntu läuft als system im moment....hilfe!

hello, I have installed on my MacBookPro Ubuntu via Boot Camp, but bootcamp has deletet that MacOS partion and created just one new and installed ubuntu. Now I can not install MacOS 10 from the DVD, the gray screen comes when I use the "C" key during the boot process. it starts booting... (2 Replies)
Discussion started by: ingwio
2 Replies

6. UNIX for Advanced & Expert Users

Crontab Eintrag geht nicht... bitte um hilfe

Hallo, ich versuche in Crontab eine Befehlszeile einzufügen, das mein Script für ein Anti Flood Tool nach jedem neustart des Servers startet. Leider kenne ich mich Linux nicht soooo gut aus. Vielleicht kann mir jemand helfen? Ich danke euch schon mal. --> der Eintrag den ich geschrieben... (7 Replies)
Discussion started by: skimoni
7 Replies

7. UNIX for Dummies Questions & Answers

Brauche SCHNELLE HILFE

Hallo, ich habe folgende Dateien: 1Lmr12345.orig 1Lmr23456.orig 1Lmr34567.orig Davon allerdings hunderte. Wie lautet der Befehl um diese Dateien umzubenennen in 1Lmr12345 1Lmr23456 1Lmr34567 also ohne die Endung und ohne den Punkt? Weiß einer was????? (1 Reply)
Discussion started by: FranzB
1 Replies

8. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies
Login or Register to Ask a Question