Can't run shell script to save my life

Hello,
I have a shell script which I need Java to start. When I pass the parameters in Java I get an exit value of 2. I never set an exit/error value of 2 in my code. What is even more strange, is that when I run the exact same strings I use in the processCommands array, the shell script starts and complete just fine. I have even tried commenting out getting the exitValue just in case my little script wasn't completely done.
Here is the code.
                ArrayList<String> processCommands = new ArrayList<String>();
                processCommands.add(processorString);
                processCommands.add(dropboxString);
                processCommands.add(name);
                for (String string : processCommands)
                    System.out.print(string + " ");
                System.out.println("");
                ProcessBuilder processor = new ProcessBuilder();
                processor.command(processCommands);
                Process ProcessPdf = null;
                ProcessPdf = processor.start();
                ProcessPdf.waitFor();
                int exitValue = ProcessPdf.exitValue();
                System.out.println("Exit Value: " + String.valueOf(exitValue));The input I am working with is:
//home//adynammic//userfiles//demo//dropbox//process.sh
//home//adynammic//userfiles//demo//dropbox
s5.pdf
The shell script even runs from the command line with all the extra slashes. I am running an Ubuntu system if that helps.
Your help is greatly appreciated,
Chem E

There are a number of things that can be going wrong.
First, get rid of the extra slashes. They're probably not causing a problem, but there's no need for them, and we might as well eliminate that variable.
Is that shell script executable by the user that's running your Java code?
Does the shell script start with a line like
#!/bin/shwhere /bin/sh is the full path to a valid shell such as bash, zsh, tcsh, etc.?
Is that shell listed in /etc/shells?
(Yes, I know, since it works from the command line, this stuff shouldn't be an issue, but, again, let's eliminate variables, just to be sure.)
Does that script assume some environment variables or pwd that might not be present when running from your Java code?
Which of those 3 commands gives the exit status of 2? Start with just one of them, and don't add the others until you get that one working.

Similar Messages

  • Can not run shell script

    Hello firends,
    I have one simple script to run orbd and one java program: I can not this script on RH linux.
    #!/sbin/sh
    case "$1" in
    'start')
    /bin/orbd -ORBInitialPort 2600 &
    sleep 5
    /bin/java NamdServer -ORBInitialPort 2600& --------This can not run.
    echo "Server is up."
    'stop')
    echo "Usage: $0 { start | stop }"
    exit 1
    esac
    exit 0
    I cound not see the process of "java NamdServer" using ps -lef after run this script. I also tried the following option with -classpath, it did not work either.
    java -classpath /disk/programs/namd_server_sparc/:. NamdServer -ORBInitialPort 2600
    java -classpath . NamdServer -ORBInitialPort 2600
    Thanks a lot.

    Hi
    When you try to execute the NamdServer do you get any output as it tries to start ? or does it fail
    silently?
    You might need to try and find out if you can run NamdServer in a verbose mode where it tells you whats its
    trying to do.
    Alternately. you can use the truss command ( man truss to find out more ) on your script.
    regards

  • [Solved] Installed grsecurity, can't run shell scripts. :|

    Fixed, it was TPE.
    For anyone else with this issue, either add your users to the TPE trusted group, or disable TPE altogether.
    https://wiki.gentoo.org/wiki/Hardened/G … _Execution
    Last edited by TheReverend403 (2014-04-14 13:05:28)

    Please remember to mark the thread as solved https://bbs.archlinux.org/viewtopic.php?id=130309

  • Can't add "Run Shell Script" in Automator

    When I drag "Run Shell Script" to the right pane in Automator nothing happens. All other applications I've tried can be dragged to the right pane. In the system.log I can find the following message:
    Feb  7 16:56:48 Bananaboat Automator[195]: Error : -[AMWorkflowView _addAction:Kör kommandotolksskript] : * -[NSTextView replaceCharactersInRange:withString:]: nil NSString given.
    "Kör kommandotolksskript" is "Run Shell Script" in Swedish.
    Any ideas how to fix this?

    You might have a corrupted file in the action, in which case you could reload it with something like Pacifist. You can't get the digest of a directory, so for comparison, compressing a copy of /System/Library/Automator/Run Shell Script.action on my desktop gives me the following:
    sha1 digest: c209b69777f6a3301d72ddf0eb0ad4e7d4230741
    md5 digest: 09e4ade9056ada3294ffb93bd16de1a7

  • Run Shell Script: Interaction?

    I use a shell script to build and edit blog articles.
    It's quite clever when on the local server where the files end up. A simple routine of building a .php file, then it launches Vim on the file it created, I make some edits to it (add the content), then save and exit Vim.
    That is it. When done on the local server, this is perfect. However, with my new upgrade to Tiger, I wanted to try using Automator to do some of this as well as the image copy and conversions which I typically do beforehand.
    The Workflow I have so far actually works but the SCRIPT part is messing with me.
    I need to have Automator launch the script in a Terminal window so I can interact with the steps it goes thru. Essentially, the launch of Vim in the Terminal opening the file that was made.
    I can't figure out how to do this. Terminal is not an app in the left pane of Automator, and when I call my script using "Run Shell Script", it does not perform the last step, "vi filename.php" - rather it completes and leaves my "Stencil" un-edited.
    How can I get this done?
    Beavis2084

    http://discussions.apple.com/message.jspa?messageID=1791477#1791477

  • Apple Automator - Run Shell Script Application

    Morning, hope somebody can point of my error please.
    I'm attempting to create an Application wrapper for a minecraft server.
    I've done the following
    Automator > Application
    I've dragged in 'Run Shell Script'
    The Shell dropdown is '/bin/bash'
    The Pass input is 'as arguments'
    In the script I have '
    cd /Volumes/3Tb/Bukkit_live
    /usr/bin/java -Xmx2G -jar /Volumes/3Tb/Bukkit_live/minecraft_server.jar nogui
    Now when I run it through the automator app, it works fine, the server starts, however when I try and run it as a standalone application it does nothing ?
    Please help.
    Thanks in advance.
    Darren

    Best guess is that there is an environment variable in your Terminal session that does not exist when you are running an Automator workflow.
    You could try running an Automator workflow that does Run Shell Script with something like
    ( pwd
      id -a
      echo $#
      echo "$@"
      printenv
    ) >/tmp/automator.environment.txt
    Then do 2 things.  Run it within Automator and copy the /tmp/automator.environment.txt file someplace safe.  Next save it as an Automator app and run it that way.  Compare the 2 automator.environment.txt files and see if anything significant is different between the 2.
    This is just a guess (an educated guess, as this sort of thing has happened to others in the past when they see a difference between running a script interactively and running it as an embedded app).

  • How to run shell script using External Process in Process Flow?

    Hi,
    We can run external process using Process flow.
    I would like to run shell script as external process in Process flow.
    Could any one please explain it?
    Thanks and regards
    Gowtham Sen.

    HI,
    As you said I tried this case. I got the following error. The script is running successfully while I tested at unix command prompt.
    The error is as follows..
    tarting Execution PFPS_SMPL_RUNSHELL
    Starting Task PFPS_SMPL_RUNSHELL
    Starting Task PFPS_SMPL_RUNSHELL:EXTERNALPROCESS
    /SOURCE_FILES/CollectFiles.sh: line 1: ls: command not found
    /SOURCE_FILES/CollectFiles.sh: line 1: wc: command not found
    /SOURCE_FILES/CollectFiles.sh: line 1: ls: command not found
    Completing Task PFPS_SMPL_RUNSHELL:EXTERNALPROCESS
    Starting Task PFPS_SMPL_RUNSHELL:EXTERNALPROCESS_1
    SQL*Plus: Release 10.1.0.2.0 - Production on Fri Sep 29 22:57:39 2006
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    ERROR:
    ORA-12545: Connect failed because target host or object does not exist
    Enter user-name: SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
    where <logon> ::= <username>[<password>][@<connect_identifier>] | /
    Enter user-name: SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
    where <logon> ::= <username>[<password>][@<connect_identifier>] | /
    SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
    Completing Task PFPS_SMPL_RUNSHELL:EXTERNALPROCESS_1
    Completing Task PFPS_SMPL_RUNSHELL
    Completing Execution PFPS_SMPL_RUNSHELL
    My scenario is---
    I am trying to return a file name from one shell script. I created a external process for that. After completion of this process, I am running another script which takes that file name and trying to create a external table. The both scripts are runnning successfully. But while I am trying to run using process flow, its not coming.
    And I am not getting the way to catch the output of external process and pass it as parameter as another external process.
    Any suggestions are welcome.
    Thanks and regards
    Gowtham Sen.

  • Can't enter shell scripts in Automator?

    When adding the "Run Shell Script" action to a workflow in Automator, I can't actually type anything in the text box -- when I try to type something, I just get a bunch of seemingly random characters. Does anyone else see the same behaviour or is there just something funky going on with my two Macs?
    I'm certain I'd be able to create a couple of services for encrypting/decrypting messages in Mail with GPG, if only I could actually type the shell script into Automator

    Redemption Code http://helpx.adobe.com/x-productkb/global/redemption-code-help.html

  • Trouble using Run Shell Script with python in Automator

    Hi. I have a python script I want to run in Automator (update_puzzles.py). All it does is check, rearrange and update files and there is not supposed to be any input. I can get the script to run outside of Automator, in Terminal, by navigating to the right directory and typing "python update_puzzles.py"
    I must not be setting up Run Shell Script correctly. I have it set to /bin/bash and Pass Input to stdin. The command line simply reads python /pathname/update_puzzles.py (where pathname is the path to the .py file, which I got by dragging the file onto the Run Shell Script command window). There are no actions before this in my workflow and the action after is View Results.
    The log says Run Shell Script failed, and the error is "Traceback (most recent call last):"
    Any suggestions?
    Thanks so much.

    If the script is expecting to do stuff with files in the same directory as the executable, you will probably need to add a statement to change to the appropriate working directory. The shell used in the Automator *Run Shell Script* action is a generic one that does not share any of the environment variables that the Terminal uses.

  • Automator runs shell script differently

    hi
    i build a little shell script that mounts my network-shares when they are available - that's works perfect if run by terminal but if i run it via Automator-Run shell script it does ******** - it doesn't seem to recognize my variables and creates dirs like $“Data“  instead of just Data
    can anyone help me with that?
    #!/bin/bash
    # connects to network shares if server available
    #config - wich server and mountpoints, login
    server=$"192.168.2.1"
    serverName=$"NAS(AFP)"
    dir=$“Data“
    dir2=$“Data1“
    login=$“xxx“
    pw=$“xxx“
    #connect-test and create mountfolders
    ping -q -c3 $server > /dev/null
    if [ $? -eq 0 ];then
      if [ -d "/Volumes/"$dir"" ]; then
      echo "folder $dir exists"
      else
      echo "creating folder $dir"
      mkdir "/Volumes/"$dir""
      fi
      if [ -d "/Volumes/"$dir2"" ]; then
      echo "folder $dir2 exists"
      else
      echo "creating folder $dir2"
      mkdir "/Volumes/"$dir2""
      fi
    #mount
      mount_afp "afp://"$login":"$pw"@"$serverName"._afpovertcp._tcp.local/"$dir"" "/Volumes/"$dir""
      mount_afp "afp://"$login":"$pw"@"$serverName"._afpovertcp._tcp.local/"$dir2"" "/Volumes/"$dir2""
      echo „ping ok“
    else
      echo „failed to connect to $serverName“
    fi

    FYI.  If you create an Alias of a mounted volume, the Alias will record all the connection information, except the password.  If your keychain is not locked, then when double clicking on the Alias, it will get the password from the keychain and mount the networked volumes (assumes you allowed the password to be stored in the keychain when you first mounted the volumes interactively).
    The Aliases can be put into your System Preferences -> Users & Groups -> Startup Items if you like.
    If this is a laptop and you are re-mounting the volumes when you get to a specific location, you might want to look at ControlPlane
    <http://www.macupdate.com/app/mac/39644/controlplane>

  • Automator - Run Shell Script - Does not return when script launches firefox

    Automator does not work the same on my MacBooks as my Mac mini! Both are latest Snow Leopard. I'm trying to automatically setup my MacBook after it decides if I'm at work, or elsewhere.
    The Automator Action "Run Shell Script" (Shell: /usr/bin/perl) does NOT return control when attempting to launch Firefox:
    system("/Application/Firefix.app/Contents/MacOS/firefox-bin -private news.google.com &");
    Note: the ampersand should cause Firefox to start as a background process.
    It only returns control after I close Firefox. I have a "Show Growl Notification" as the second action, so I know that the first action has not completed. Odd thing is that this works on my Mac mini. I also noticed that another difference: on my MacBook status is displayed in the top toolbar when the Automator application is running.
    Any ideas?

    Thanks, it worked. I forgot about stderr and stdin.
    I'm using Perl as it is part of a bigger script. I can quickly and easily figure out if I am at work where my MacBook is plugged into a network:
    my $ethernet = qx(ifconfig en0) =~ m{status:.active}xms;
    if ($ethernet) {
    # setup stuff for work environment
    } else {
    # setup stuff for mobile environment
    }

  • Run shell script as root on boot

    Hi!
    I have the need to run a shell script on boot up as root.
    It will not run as any other user because the software that the shell script runs requires root permissions, and I don't use my computer as root. I can't run it at login and use sudo because it would ask for a password and hang.
    How can I have the shell script auto-run at boot (or login) as root?
    Thanks
    Ross

    Hi,
    first of all you can store your shell script anywhere on your system, I prefere the location /usr/local/scripts (this doesn't exist by default).
    Second you have to create a LaunchDeamon script in /Library/LaunchDeamons which execute your shell script at boot as root.
    An example:
    -------------------------snip------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST
    1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>YOURIDENTIFIERNAME</string>
    <key>ProgramArguments</key>
    <array>
    <string>/usr/local/scripts/YOUR_SCRIPT.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>UserName</key>
    <string>ROOT</string>
    <key>GroupName</key>
    <string>WHEEL</string>
    </dict>
    </plist>
    -------------------------snap------------------------
    http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemS tartup/Articles/LaunchOnDemandDaemons.html
    To run a script as root during a user login you can configure a LoginHook. To create a LoginHook login as the relating user and type the following commad:
    sudo defaults write com.apple.loginwindow LoginHook /Path/To/Your/Script
    http://support.apple.com/kb/HT2420
    Hope that helps
    Bye Tom

  • Can we call shell script from oracle 9i?

    Hi experts,
    I wanted to know can we call shell script from oracle 9i procedures? If yes,how
    Thanks
    Shaan

    No. I can't think of a way to do this...
    If you want you can use DBMS_SCHEDULER to call OS SHELL scripts within.
    For e.g.
    CREATE PROGRAM
    begin
    dbms_scheduler.create_program
    program_name => 'CHECK_TIME',
    program_type => 'EXECUTABLE',
    program_action => '/opt/oracle/chk_date.sh',
    enabled => TRUE,
    comments => 'Check the Time'
    end;
    CREATE A SHELL SCRIPT
    opt/oracle> cat chk_date.sh
    #!/usr/bin/ksh
    echo "The date is :`date`"
    CREATE SCHEDULE
    begin
    dbms_scheduler.create_schedule
    schedule_name => 'EVERY_30_MINS',
    repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
    comments => 'Every 30-mins'
    end;
    CREATE JOB
    begin
    dbms_scheduler.create_job
    job_name => 'RUN_CHECK_TIME',
    program_name => 'CHECK_TIME',
    schedule_name => 'EVERY_30_MINS',
    comments => 'Run the program CHECK_TIME every 30 minutes',
    enabled => TRUE
    end;
    MANUALLY RUN A JOB
    exec dbms_scheduler.run_job('RUN_CHECK_TIME');

  • Output from Run Shell Script action

    Does anyone know what happens to the output of a "Run Shell Script" Automator action if there are no further actions? Does it simply get discarded, or does it end up in a log somewhere?

    It's the same for any action, nothing.
    The results passed on to the next action is generally just a list of file paths, or perhaps some text, or maybe a reference to a single item. In the "Run Shell Script" case, the result would likely simply be some text, perhaps as a list of lines.
    So, if there are no more actions, any of those results are just dropped.
    However, a list of files (or whatever) is actually just part of the results. An action performs some task on the input, or on the results from a previous action. In a sense, there can be said to be two parts to the "results". For example, perhaps an action changes some photos to black & white, so the photos will have been changed and then the paths to the photos (list of items) will be passed to the next action. The list of items is the only usable part for the next action, if there is a next action.
    You can use Automator's "View Results" action after it to see the results, TextEdit's "New Text File" to create a file with the previous results as the contents, TextEdit's "New TextEdit Document" to open a new document with the results as the document's contents, and so on.

  • Running shell scripts from GUI

    I'm trying to run a simple shell script (bash or sh) from the GUI (just double click it).
    I've managed to run it by double clicking, BUT, it runs from my home directory (even if i add --noprofile or remove #!/bin/bash line completely).
    How can I keep the current directory, or at least get it as a variable?
    Thanks,

    Hi
    If you are using the Oracle database 10g, the new dbms_scheduler package allows you to run shell scripts. The dbms_scheduler.create_job procedure have one parameter called the job_action in which you specify the full path of the shell script.
    I hope this will help

Maybe you are looking for

  • 24inch iMac with Mini-Dvi to VGA adapter, is not working correctly!

    OK, I PLUGGED MY ADAPTER TO THE VGA CABLE FROM THE OPTOMA PROJECTOR AND THEN CONNECTED THE ADAPTER TO THE 24IN IMAC. I USED THE REMOTE FOR THE PROJECTOR AND SELECTED VGA 19(WHAT PORT COMPUTER IS CONNECTED TO) AND ALL I SEE IS MY WALLPAPER, NOT ONLY T

  • Office 2008 and Acrobat Pro v9.1

    I have recently installed Acrobat Pro 9.1. On my Mac using 10.5.6 I have also installed Microsoft Office 2008. Office was installed before Acrobat What I cannot do is make an office document into a pdf unless I print from the application. This is a p

  • Viewing RAW file thumbnails in Adobe Bridge

    Hello folks have a problem which is driving me crazy and I'm hoping someone might be able to give me some pointers. Until recently I was able to view my NEF RAW files as thumbnails in Bridge, click on them and they open in camera raw fine. But all of

  • Beware: conversion error with dates

    When I converted my pdf to xlsx format, some dates in a table were not converted correctly. In the pdf file, the dates were in mm/dd/yyyy format, but if the day was between 1-12, Export PDF treated the date as if was in dd/mm/yyyy format. It couldn't

  • Logic Expres on a G4

    Hi I got an ibook G4 and i install a logic express on it, do you think that is to much software for the computer? i dont use a lot of tracks and effects, just for an littlehome studio.