Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo,

ich will mir ein Programm samt gui basteln um MAC Drucker per Klick oder später Checkbox-Auswahl installieren zu können.

Problem:

Ich schaffe es weder den Unix- (lpadmin..), noch den applescript- (do shell script "lpadmin..") Befehl aufzurufen.

Momentan habe ich ein applescript, welches die Drucker installiert und ich rufe in Java diese applescript datei auf.

Problem dabei ist, dass ich die applescript datei ja als Pfadangabe angegeben habe. Das Programm funktioniert dann also nichtmehr sobald ich es iregndwo anders hin verschiebe, z.b. auf anderen Rechnern verteile.

Kann mir jmd. helfen wie ich das am besten löse?

Hier mal der Quellcodes

UNIX-Befehl:

lpadmin -p 5570_EDV -E -v lpd://192.168.15.52 -P /Users/Shared/Druckerbeschreibungen/Canon\ iR5570-6570-M3\ PS\ Ver\ 1.1
applescript:
do shell script "lpadmin -p \"5570_EDV\" -E -L \"EDV Gang\" -o printer-is-shared=false -v lpd://192.168.15.52 -P /Users/Shared/Druckerbeschreibungen/Canon\\ iR5570-6570-M3\\ PS\\ Ver\\ 1.1"
Java Funktion um die es geht:
        //Funktion Button "5570 EDV"

        b_5570_edv.addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent e)

            { String cmd="osascript /Users/heinle/Desktop/printer\\ scripts/install\\ 5570_EDV.app"; UnixComm(cmd);}

        });
der gesamte code (falls benötigt):

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import java.io.IOException;

import java.io.BufferedReader;

import java.io.InputStreamReader;


/**

 * @author andreas heinle

 *

 */


class mpinstall {

    //Deklaration

    private Frame f;

    private Panel pOben, pUnten;

    private Label l, l2;

    private Button b_5570_edv, b_clc_4040, b_ImagePressC1, b_clc_1100_pharma, b_ir5570_crea_3og;


    //Erzeugung

    public mpinstall()

    {

        f = new Frame();

        pOben = new Panel();

                pUnten = new Panel();

        l = new Label("Zu installierende Drucker auswählen:");

        l2 = new Label("");

        b_5570_edv = new Button("5570 EDV");

                b_clc_4040 = new Button("CLC 4040");

                b_ImagePressC1 = new Button("ImagePress C1");

                b_clc_1100_pharma = new Button("CLC 1100 Pharma");

                b_ir5570_crea_3og = new Button("IR5570 Creation 3.OG");


    }


        //vorbereitung zum aufruf der applescripts

        public static String UnixComm(String cmd){

        try{

            Process Results=Runtime.getRuntime().exec(new String[] {

                "/bin/sh","-c",cmd});

            //Results.waitFor(); //- Add this line if and only if you aren't collecting any data but need the command line stuff to have finished before continuing.

            //If you don't need either then you can remove 'Process Results=' from the line above.

            BufferedReader br=new  BufferedReader(new InputStreamReader(Results.getInputStream()));

            String s=br.readLine();

            br.close();

            br=null;

            Results=null;

            return s;

        }

        catch(Exception e){

            return "Error with UNIX Command";

        }

    }


    //Festlegen der Eigenschaften des Programms

    public void frameFestlegen()

    {

        f.setTitle("Heye Druckerinstallation (Macs)");

        f.setSize(500,300);

        f.addWindowListener(new WindowAdapter()

        {

            public void windowClosing(WindowEvent e)

            { System.exit(0); }

        } );


        //Elemente platzieren

        //Layout pOben

        pOben.setLayout(new GridLayout(3,1));

        pOben.add(l);pOben.add(l2);


                //Layout pUnten

                pUnten.setLayout(new GridLayout(2,4));

        pUnten.add(b_5570_edv);pUnten.add(b_clc_4040);

                pUnten.add(b_ImagePressC1);pUnten.add(b_clc_1100_pharma);

                pUnten.add(b_ir5570_crea_3og);


        //Fenster Layout

        f.setLayout(new BorderLayout());

        f.add(pOben, BorderLayout.NORTH);f.add(pUnten, BorderLayout.CENTER);


        //Funktion Button "5570 EDV"

        b_5570_edv.addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent e)

            { String cmd="osascript /Users/heinle/Desktop/printer\\ scripts/install\\ 5570_EDV.app"; UnixComm(cmd);}

        });


                //Funktion Button "CLC 4040"

        b_clc_4040.addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent e)

            { String cmd="osascript /Users/heinle/Desktop/printer\\ scripts/install\\ CLC\\ 4040.app"; UnixComm(cmd);}

        });


                //Funktion Button "ImagePressC1"

        b_clc_4040.addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent e)

            { String cmd="osascript /Users/heinle/Desktop/printer\\ scripts/install\\ CLC\\ 4040.app"; UnixComm(cmd);}

        });


                //Funktion Button "CLC 1100 Pharma"

        b_clc_4040.addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent e)

            { String cmd="osascript /Users/heinle/Desktop/printer\\ scripts/install\\ CLC\\ 4040.app"; UnixComm(cmd);}

        });


                //Funktion Button "iR5570 Creation 3.OG"

        b_ir5570_crea_3og.addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent e)

            { String cmd="osascript /Users/heinle/Desktop/printer\\ scripts/install\\ 5570\\ Creation\\ 3OG.app"; UnixComm(cmd);}

        });


    f.setVisible(true);

    }



    //Hauptmethode

    public static void main(String[]args)

    {

        mpinstall fenster = new mpinstall();

        fenster.frameFestlegen();


    }

}

Vielen Dank für die Bemühungen :)

Andreas

PS: Ich nutze NetBeans dafür

Ich versteh nicht so ganz wie du das mit dem Suchpfad meinst.

Es geht darum das wir ca. 100 Drucker haben und täglich an verschiedenen Rechnern verschiedenste Drucker davon manuell installieren müssen.

Es sind auch helios Drucker dabei, also verdammt viel copy & paste Arbeit (stunden).

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.