Java GUI for a shell script

I have a file with passwd format.I made a script for this file that is working as I wanted it to work.I have a list of options and each time I give an option,the script is doing something(for example,if I press "b" it makes something and if I press "a" it makes something else).All the results are an output from the file.
My question is how can I create a GUI in java for this script.For example if I want the script to do what it would do if I pressed the "a" button on my keyboard,but not by pressing "a",but by choosing from a drop down list or some other graphical feature(by ticking a check box,clicking a button etc).Can I do this with java?
Lazaros

Hi,
I understand you can create a Java Swing gui for a bash shell script which takes both complex input and writes output to the stdout & files, to be specific. Is that correct?
If yes, could you give a simple example. Say for the following shell script.
#!/bin/sh
printf "Enter input\n"
i=0
while [ $i -ne 1 ]; do
read $inputVar
if [  "$inputVar" == "y" ]; then
printf "You typed yes\n"
i=1
elif [  "$inputVar" == "y"  ]; then
printf "you typed no\n"
i=1
else
printf "Enter a valid character\n"
i=0
fi
done
Could you also point to some URL's which might help? Googling for "Java Gui for shell script" returns this as the first page, others dont really help. Googling "GUI for shell script" returns all other gui toolkits for xes but thats not what I want. I want a cross platform (nixes, Win*, MacOS* ) gui for a shell script ( which I plan to run using cygwin etc).
TIA
Vinod

Similar Messages

  • How to run a java class from a shell script with passing arguments

    hi,
    I have a jar with all the required classes. I was using ant to run the classes i needed.
    But now i want to use a shell script to run the class, also the class accepts some arguments so when script is run it should accept arguments.
    So can any one tell me how to set class paths, jar location and call the required class from shell script or batch file with passing arguments to it.
    Thanks in advance.

    Let's say that the order of arguments is as below
    1. Jar file name
    2. Classpath
    Your shell script would look like this
    java -cp $CLASSPATH:$2 -jar $1 I am assuming that your jar file has the required main-class entry in its manifest. Note that $1...$9 represent the arguments to this shell script.
    The same goes for a batch file
    java -cp %CLASSPATH%;%2 -jar %1

  • Use java to run a shell script which called a crontab command at Unix

    I was trying to write an automate function using Java, which needs to call a shell script containing a crontab commend. The shell works fine without that crontab commend, but once I add it, the program won't execute that crontab commend.
    public void cron(){
    try
    Process proc = Runtime.getRuntime().exec("script1");
    BufferedReader br = new BufferedReader(new           InputStreamReader(proc.getInputStream()));
    String line;
    while ((line = br.readLine()) != null)
         System.out.println(line);
    int returnValue = proc.waitFor();
    br.close();
    } catch (Exception e){} //
    script1:
    #!/bin/sh
    crontab cronfile
    Can someone help me out for this? Thank you.

    Try this....
    Process p = Runtime.getRuntime().exec("sh");
    java.io.BufferedWriter bw = new java.io.BufferedWriter(new java.io.OutputStreamWriter(p.getOutputStream()));
    bw.write("script1");
    bw.flush();
    bw.close();

  • Java exec() of UNIX shell script

    I have a java application that uses:
    p = Runtime.getRuntime().exec( cmdLine);
    to execute a UNIX shell script, for example:
    #!/bin/ksh
    . /export/pc112477/freeware/work1/wsEnv
    export PATH=/opt/sfw/bin:/usr/ccs/bin:/usr/bin:/usr/ucb:$PATH
    cd /export/pc112477/freeware/work1/usr/src/pkgdefs/SFWnmap
    /usr/ccs/bin/make -e ROOT=$ROOT install
    RESULT=$?
    if [ $RESULT = 0 ]
    then
    echo "Package source"
    cd /export/pc112477/freeware/work1/usr/src/pkgdefs/SFWnmapS
    /usr/ccs/bin/make -e ROOT=$ROOT install
    RESULT=$?
    fi
    exit $RESULT
    Some times the running of the script locks up depending on how much work the script has to, eg. if the make calls pkgmk for a small package it runs okay but if its a large package it locks up in pkgmk.
    The script itself works okay if run directly
    Does anyone have any ideas on why this locks up and how I could stop it doing it.
    Thanks

    For anyone who stumbles across this and needs an answer:
    To empty the standard error and output, you need to use getErrorStream() and getInputStream() on the Process object created when you execed your command. Create new InputStreamReaders with the streams from the process, then wrap those with BufferedReaders and read each line with a while loop. This is the basic thing you need to do:
    try{
    Process proc = Runtime.getRuntime().exec(command);
    InputStreamReader isr = new InputStreamReader(proc.getErrorStream());
    BufferedReader errReader = new BufferedReader(isr);
    String line;
    while((line = errReader.readLine()) != null)
    <do something with each line of error>
    } //end try
    catch(<errors>) {
    <do something with errors>
    } //end catch
    What you really should do is put the stream handling in a separate class that extends Thread, create an instance for the error and output streams, and start each one. There is a class called StreamGobbler that does this sort of thing. Look at http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html to find out more about it and read a detailed explanation of different problems with exec().

  • Invoking a java program from a shell script!

    Can this be done?
    Ive written a simple compiler for the language buru which just reads/parses and then executes a file for this java like language. But what Im wondering is if I can write a shell script something like this
    #!/bin/bash
    java Interpreter one.buru
    this isn't working so its not correct but if someone knows how to do so there are duke dollars going for it Cheers :)

    The most likely reason is that java is not finding your class.
    That is probably because when you execute the script the "working directory" is not in a location that works with your class path.
    You should be able to find the working directory and class path with the following commands (or some variation of them) added to the beginning of your script.
    cd
    echo $CLASSPATH

  • Trouble in Unix calling a Java utility from another shell script

    Hi,
    I'm able to run a shell script (call it script B) in Unix which calls a Java utility. When I call script B from another script (script A) I get the error below. I have done much work to make sure the environment variables are the same.
    java.util.zip.ZipException: error in opening zip f
    ile
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:69)
    at com.something.runtime.ZipFileApplicationSource.<init>(ZipFileApplicationSource.java:22)
    at com.something.runtime.ZipFileRuntime.main(ZipFileRuntime.java:35
    ANY HELP WOULD BE GREATLY APPRECIATED.
    Thanks

    Here's my guess, if this doesn't work, post your scripts and maybe that will help.
    When you run your script B, you said it works. I think the problem is that when you run script B, your shell and envirenment variables are set by the window you're working in. When you call script B from script A, it creates a new shell to run it and it doesn't run the files that are run when you start a terminal or a telnet(it won't run .cshrc, .kshrc or .login). Depending on what OS you're using, I think the default shell is sh for most of them. The first line of script B should be
    #!/(your bin directory)/(shell you're using)
    for me it's
    #!/bin/tcsh
    then you might want to run your startup file to set envirenment variables, paths, etc...
    source (your user directory)/(the file name)
    for me it's
    source ~/.cshrc
    Then if you need to set the environment variables in your script.
    set CLASSPATH /usr/local/j2ee/bin.....
    set PATH /bin:/xyz....
    If that doesn't help post your scripts, or if I didn't explain it will enough, just ask.

  • Creating a Java GUI for a C/C++ program

    I'm tasked with creating a GUI for a multi-threaded C++ network server program that has it's main function running with a while loop that checks for keystrokes from the user. The C++ code for the loop is basically:
    while(i!='q')
    if(kbhit())
    i=getch();
    processkey(i);
    }And the processkey function performs different actions based on the key that was pressed.
    I was reading up on ways to interface between Java and C/C++ and heard of JNI, but I also found someone who suggested using the Java Robot class to send the keystrokes from my GUI to the C++ program.
    I've been trying to make a small test case application using the Robot class before trying to implement it in my larger project.
    I created a program with a JFrame with two buttons, one starts a simple C++ program that loops, waiting for keypresses and which will close when 'q' is pressed, like my main program.
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
            try {
                Runtime.getRuntime().exec("C:/Users/Administrator1/Desktop/Untitled2.exe");
                // TODO add your handling code here:
            } catch (IOException ex) {
                Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
            // TODO add your handling code here:
        }The other button creates a Robot instance and tells that robot to send a key press of 'q', which should terminate the C++ program.
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
            try {
                Robot robot = new Robot();
                // Creates the delay of 5 sec so that you can open notepad before
                // Robot start writting
                //robot.delay(5000);
                robot.keyPress(KeyEvent.VK_Q);
            } catch (AWTException e) {
                e.printStackTrace();
        }It isn't working though. Could it be because when the program is started from my Java app, it runs in the background rather than opening in a new command prompt window? Or is Robot not the way to go, and if so, are there any examples and/or tutorials online that could help me?

    When you clicked the button, what application do you think has the focus at that point? So what do you think consumes the keystroke that you emulated? Hint: It wouldn't be the application you intended it to go to.

  • Java GUI for Unix not showing . files

    we have discovered a strange behaviour with sapgui 7.10 rev 8 on unix (AIX and Solaris). You can't see and browse to folders starting with a . (e.g. .abc) and also files with a . are not listed in the file open dialog (for attaching files via cv02n). Does anybody experience the same behaviour and probabely has found a setting to change it?
    Thanks for any help
    Axel

    Hi Axel,
    it sounds a bit odd that this CAD integration software is writing files to hidden folders but the user later is forced to navigate inside there.
    SAP GUI for Java inherits the file chooser dialog from the Swing framework part of Java. Sun seems to have decided, that by default, hidden files and folders should not be shown.
    I am hesitating to generally switch on showing hidden files and folders because it will irritate most end users.
    We are looking into a way to add the option to switch on showing hidden files and folders by the user.
    Btw, the user can navigate into a hidden folder by entering its name and hitting return, from there the user can navigate as usual. So it is not required to enter a complete path.
    Best regards
    Rolf-Martin

  • Quick and easy fix for linux shell script in 1.2.1.32.13

    Hello, right after installing sqldeveloper in my home directory and linking the script in my bin dir I found a small problem with the shell script for linux.
    I downloaded the "Multiple platforms" zip file.
    here is the fix:
    change "dirname $0" to "readlink -f $0 | xargs dirname"
    with this fix, linking to the shell script won't cause the script to use the bin dir instead of the real directory where sqldeveloper is installed.

    This symptom occur because a 64-bit process that runs on a computer that is running an x64-based version of Windows cannot load the 32-bit .dll files that are required by some program features.
    You may try the following work around:
    You must use the 32-bit version of Windows Explorer. The 32-bit version of Windows Explorer is located in the %windir%\Syswow64 folder on the computer that is running an x64-based version of Windows.
    To use the 32-bit version of Windows Explorer, follow these steps:
    Click Start, click Run, type the following in the Open box, and then click OK:
    Drive_Letter:\windows\syswow64\explorer.exe /separate
    Note The placeholder Drive_Letter represents the drive where the x64-based version of Windows is installed.
    For more information:
    Some Windows Explorer extensions and some Control Panel items are not displayed on computers that are running an x64-based version of Windows
    http://support.microsoft.com/kb/895561#appliesto
    Now check if the issue is resolved.
    You may want to try the following steps:
    PDF thumbnail view via the Acrobat reader:
    1. Run Acrobat Reader. In Reader, click File > Open and navigate to the folder(s) containing your PDF file(s). If necessary, move the slider to show all your PDF files.
    2. Cancel out of Open and exit Reader.
    3. Open Windows Explorer and navigate to the folders(s) containing your PDF file(s).
    4. Click Views and move the slider until you see PDF thumbnails.
    Thanks and Regards:
    Sanjay Manju Suman
    Adobe System Inc.

  • Cannot read list of frontend printers - Printing in SAP JAVA GUI for MAC

    Hello,
    I am trying to print a Spool request in SAP Java GUI 7.10. I am working on Apple with OSX operating system. I get this error message -
    " Cannot read list of frontend printers " - Message no. PO781
    What do i need to do to take a print out from SAP on my Mac.
    Thanks
    Buddy

    Hello,
    which printing access method you are using?
    You might want to have a look at [note 821519|https://service.sap.com/sap/support/notes/821519].
    Best regards
    Rolf-Martin

  • Forum for Unix Shell Scripting ?

    I an an oracle DBA working on AIX, Solaris environments. Which is the best forum to post questions on Shell scripting? I tried forums.sun.com , but replies are very slow, relatively speaking(forums.oracle.com).

    GarryB wrote:
    I an an oracle DBA working on AIX, Solaris environments. Which is the best forum to post questions on Shell scripting? I tried forums.sun.com , but replies are very slow, relatively speaking(forums.oracle.com).You might try usenet. Easiest free access is via groups.google.com. I don't have access now (my employer blocks that site) but what you want to find is 'browse all of usenet', then drill down through the 'comp' domain.
    Also, two very valuable books:
    Unix in a Nutshell
    Learning the Korn Shell
    both by O'reilly Press

  • Java and Shell Scripts

    I have created a java program that its main target is to read from a log file. The GUI has six buttons and its button has a script running each time the button is being hit. The results of the script are presented on a JTextArea automatically. So I have six buttons and six scripts. The problem is that the first time the program works fine. But if I click one button for the second time I get no results or wrong results. The scripts alone(when they work without the java program) work right.
    Is this a memory problem? How can I have the scripts with the java program work right together? I must say that each script needs 4-5 seconds to execute and immediately after the execution, the results, as I told before, are shown in a JTextArea. How can I solve the problem, so that I have the right results every time I click the buttons and not just for the first time?
    I need your ideas as soon as possible. :)))
    For connecting the java program and the shell scripts I use:
    Process proc = Runtime.getRuntime().exec("bash script ");
    OutputStream out = proc.getOutputStream();
    PrintWriter p = new PrintWriter(out);
    p.flush();     

    I think u must use process.waitFor() method .
    By this, u r sure that the said process shall complete.
    Also I would recommend new Instance/Thread for running each script.

  • Invoking unix shell scripts from java?

    Hi,
    could someone explain to me how one wuld invoke unix shell scripts from java.
    Also, could you invoke Visual Basic scripts from java.
    Finally, could you do this from an EJB?
    thanks for any help....
    sudu

    I just posted a snippet of this solution in the topic about widows commands chech it out it works just fine for unix shell scripts.
    --Ian                                                                                                                                                                                                                                                                                       

  • Can a java app pass values to a c-shell script?

    hello everyone,
    I'm running a shell script that executes a java app.
    I need to pass values from the java app to the shell script, such that I can code
    java myapp
    echo <value1>
    echo <value2>where value1 and value2 have been set in the app.
    is there a way to do this?
    Thanks for your help.
    Tom

    Wira, I've tried this, and can't get it to work. The
    problem may be that Runtime.getRuntime().exec() is
    running the script on a separate process(?), Yep.
    and I
    never see any output in the same context as the
    script that's running the java app.
    I've tried this from the command line as well, and I
    don't see any output from the script being called
    from the java app.
    I know the script is being run, because if I change
    the script name to a name that doesn't exist, I get
    an ioexception, when I change it back everything runs
    ok.
    Note that I'm testing this under XP with batch files;
    eventually it will run on unix.
    does that make a difference right now?Forget java for right now.
    Start working on a way for the script to hoist the values into itself.
    For example if the script calls another script which does the echo what happens?
    Or can you call another script, set some env variables, and then see them in the original script?

  • Passing password from shell script to Java

    Hi there,
    I have a shell script which has user id and password stored in variables. I call a java program from this shell script. I tried accessing this environment variable from java using system.getproperty and java is not getting the values. I have used export USERID PASSWORD
    and java classname to call it.
    I do not want to pass it as arguments because of security reasons. can anybody help me please.
    Thanks a bunch.

    Hi there,
    I have a shell script which has user id and
    password stored in variables. I call a javaprogram
    from this shell script. I tried accessing this
    environment variable from java using
    system.getproperty and java is not getting the
    values. I have used export USERID PASSWORD
    nd java classname to call it.
    Presumably you are using one of the newer java
    versions.
    Questions
    1. What statements are you using to set, export and
    run java?
    2. What shell are you using?
    3. How are you accessing the vars in java?
    I do not want to pass it as arguments because of
    security reasons. can anybody help me please.
    That is nonsensical. Putting it in env vars exposes
    it more than passing it as args.Thanks for replying jschell.
    1. I am using newer version java 1.5
    2. shell scripts gets it's variables from oracle reports through webservices.
    3. to run java i use java javaclassname3. I used EXPORT variablename and in java called system.getproperty(variablename)But system.getproperty is getting a null.
    And the decision about not passing it as args was made by our client. They think it's not safe to pass password.
    are they wrong??
    Please help me.

Maybe you are looking for

  • Excise invoice for semifinished goods

    Hii all,           m doing a MIGO for a Excisable SemiFinished material , i have maintained J1iD for this material with Material and Chapter-ID combination correctly, during MIGO  getting a error, Excise Invoice cannot be captured for RG1(Finished Go

  • Help with XPathAPI

    Hi all, I'm using XPathAPI to navigate an already DOM Parsed XML segment of a file and I have problems with the navigation through it.The segment looks like this: <tag>1222 <tag>5543 <tag>2445</tag><tag>9999</tag> </tag> </tag> I know that is not the

  • Error applying xMII 12 sp2

    Hi all, We have SAP xMII 12.0.0 and trying to apply the SP2 using SDM. Following error occurred during this process ... Reason: Application alias [XMIIVirtual] for application [sap.com/xappsxmiiear] already exists in the HTTP Provider Service. The ap

  • Report.Services 2008 - get page-count or row-count in the c#-code

    hello is it possible to get from the ReportViewer-control / ServerReport the page-count or row-count after the reportViewerCheck.ServerReport.Refresh(); statement ?? many thanks in advance for any clue & regards Michael

  • My apps won't load after updating to iOS4.3.2. What to do?

    My apps won't load after updating to iOS4.3.2. What to do?