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.

Similar Messages

  • Run Shell Script

    Hi,
    I'm new to Automator so I don't really know what to do:
    What I want to do is run this line and create an "application" for my dock
    virtuoso-t -f -c /usr/local/var/lib/virtuoso/ontowiki/virtuoso.ini &
    so I choose "Run Shell Script" Workflow in the Automator Menu. Set the Shell to /bin/zsh (that's what im using) pass input: to stdin.
    The workflow runs with no errors, but the virtuoso server does not start
    any ideas?
    Thanks daniel

    The shell used doesn't have any of your environment variables (it is just a generic shell with no custom settings), so if virtuoso isn't in the standard path it won't be found. It is usually a good idea to use full paths anyway, especially when using Automator's Run Shell Script or AppleScript's do shell script. I am also going to guess that the missing space between the -t option is a typo.

  • 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 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

  • How to use "do shell script" when Terminal replies with a prompt?

    Hey all,
    I'm wondering how to properly use "do shell script" when Terminal replies with a question? In this example, I'm building a small tool in AppleScript that will auto-update the Android SDK via command line prompts. The problem is when I tell it to update all ("update sdk --no-ui"), I need to accept licence agreements before it continues, and the amount of licence agreements brought up is different every time.
    So, basically, I'm wondering how to handle a case where "do shell script" encounters a case where Terminal would normally need a user's response to?
    Thanks,
    Behn

    If it is variable number of prompts that is a problem.  Look around hd and figure out how many prompts there will be. Ask around android forum for a bash solution. There are some test case apps that will let you put conditionals on output from running programs.
    # traditional way.  Pipe output to command.
    do script "echo 'ok' | update sdk --no-u"
    Here is the preferred way of getting administrator privileges.
    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
        Author: rccharles
        For testing, run in the Script Editor.
          1) Click on the Event Log tab to see the output from the log statement
          2) Click on Run
        For running shell commands see:
        http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
    on run
        -- Write a message into the event log.
        log "  --- Starting on " & ((current date) as string) & " --- "
        --  debug lines
        set unixDesktopPath to POSIX path of "/System/Library/User Template/"
        log "unixDesktopPath = " & unixDesktopPath
        set quotedUnixDesktopPath to quoted form of unixDesktopPath
        log "quoted form is " & quotedUnixDesktopPath
        try
            set fromUnix to do shell script "sudo ls -l  " & quotedUnixDesktopPath with administrator privileges
            display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
        on error errMsg
            log "ls -l error..." & errMsg
        end try
    end run

  • 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.

  • How to pass video file name to run shell script

    Trying to make an automator script that will 1. Start a video capture, 2. Stop video capture, 3. Rename video, 4. Run Shell Script. Here is the shell script:
    for f in "$@"
    do
    echo "$f"
    /usr/bin/podcast --server my.podcast.server --user myself --pass mypass --submit --file $f --workflow "my workflow" --metadata /path/to/file
    done
    Question:
    Do I need to create a variable in the automator script to pass it to the script? If I need the variable do I also need to use both Set Value of Variable and Get Value of Variable? If I don't need a variable does $f need quotes around them?

    I'm not familiar with the terminal command /usr/bin/podcast so I don't know what it does but what i said is correct. to pass a file to this action you don't need any variables. the previous action in the workflow should output the video file you want to process, that's all. how you arrange that is up to you. it's clear that you have to fill in appropriate things in that shell script like " my workflow" and path to metadata. But if you have questions about how this shell action works you should ask people who made it.

  • How do you pass shell scripts with cocoa?

    How do you pass shell scripts with cocoa?

    You asked for more detail -- I don't know if this is what you were referring to or not, but here's a little more detail on how to use the system() function if that's what you wanted to know.
    As etresoft mentioned, the system() function can be useful for the kind of thing you are talking about. You will need to write the following statement at the top of your code if you want to use it:
    #include <stdlib.h>
    To use the system() function, simply put the command as you would write it in the Terminal between double quotes between the parenthesis. For example, something as simple as:
    system("ls");
    I don't what the practical use of the above statement would be, but it will run, and that's the general format for the system() function. So just put between the quotes whatever command you want to send.
    Hope there was something helpful here.

  • Running Shell Script

    Hi all,
    I need to run shell script on one of linux servers while executing some IdM workflow.
    There is no need to manage that server/ provision accounts / reset passwords etc but just to run the script and to process the result.
    I have IdM 8.04 installed on Windows Machine.
    What are my options to achieve that mission?
    Thank You,
    Alex.

    I was considering a situation similar to AD after actions where sometimes we execute a dos batch file for any specific purpose like creating home folder using mkdir. I was thinking on similar lines if your shell script is also for a specifc function similar to the one I mentioned above and if it is applicable in windows environment, you might covert that into a dos batch and do similar to an after action.
    Since you need your shell script to be run in UNIX / LINUX machine, I do not see any other way other than writing a java class and invoke within a wf as it was mentioned by etech or if you are planning on using any of the out of the box resource adapters, the AIX resource adapter reference might help, but I have not worked with that

  • Automator and "Run Shell Script" error

    First, if I'm in the wrong place with this- sorry. Figured this was an OS kind-of thing.
    I recently migrated to a new iMac ... I brought along an Automator script; I've been using it for years to perform a little rsync backup to an USB HDD. It's 'never' given me any problems ... until now!
    "*Run Shell Script*" encountered an error .. but alas, the system log is devoid of messages ... and the verbose log I have running indicates that all the files are copied/backed-up ... I would love any input on this that might help me get back on the feet. .....
    *Here's what my Shell Script Looks like:*
    Shell Option: /bin/bash
    Pass Input: to stdin
    rm -dfr '/Volumes/Backup HD/*********'
    rm -dfr '/Users/***********/Library/Logs/Profile_Backup.log'
    rsync -rltv /Users/******** '/Volumes/Backup HD/' > /Users/*******/Library/Logs/Profile_Backup.log
    (I'm sure there's way to only sync the changed stuff between backups ... but I've simply preferred the fresh copy approach).
    *I do however note this in my logs when I open Automator:*
    12/14/10 3:15:46 PM [0x0-0x42042].com.apple.automator.Backup[464] Application Stub: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

    @Tony T1
    Thanks, I'll certainly adjust the log file as suggested
    In troubleshooting the problem I went the terminal route - and issued each command ... during the rsync process I was getting an error ... turns out when it was syncing the SyncServices folder it was encountering a copy of the keychain ... which had root permissions - naturally rsync was not able to copy the file (personally I have no idea why the keychain would be being sync'd with anything)!
    I removed the file from the sync ... I'm still doing some "debugging" to correct the problem-
    Again, thanks for the assist!

  • 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.

  • Perl's __END__ doesn't work under Automator's Run Shell Script action

    Howdy,
    I have a large embedded data file in my Perl source file using the _END_ token. It works great at the command line, but when I copy and paste my Perl code into the Run Shell Script code window and execute it, reading the special file handle DATA always returns 0 lines.
    Help?
    -Eric

    Originally I was using $@ to parse a string and get the result pasted by the service. That was a while ago. There, I noticed that some Japanese characters were messed up. Basically all the kana characters that come with voicing markers like が-ga (instead of か-ka) etc. I did not have the time to pursue that issue though.
    Then, last night, I found that a colleague of mine had tried to use $@ to feed to a local dictionary application called ding (http://ftp.tu-chemnitz.de/pub/Local/urz/ding/). His problem was with characters that had umlauts. After verifying how he wrote his action I remembered that I had similar issues with Japanese.
    Basically his command was "/path/to/ding $@"
    That's supposed to use the selected string as an argument to pass to ding, which will launch a Wish application where the string is used as the searched item.
    From Terminal, that works a treat. But the exact same line in Automator (with input as argument, not as stdin) messed the composition and the resulting string was not recognized by ding as a match to what it was supposed to match.
    So, I tried a few things to get to the core of the issue and found that a simple "echo [accented characters]" was enough to reproduce the difference in string handling between Automator and Terminal. That difference is also reproduced on a number of person's machines.
    I have a number of services that basically revolve on "run shell script" actions and involve 3rd party application outputs, preference files etc. so it would not be convenient to show that to you.
    I have sent a mail about this issue to the automator list yesterday too:
    http://lists.apple.com/archives/Automator-users/2011/Jun/msg00004.html

  • How to prevent Automator's "run shell script" to create fully decomposed forms of my strings ?

    I am using Automator's "run shell script" and I am seeing that it outputs fully decomposed forms of my strings.
    For example, when I set the action to "echo été" in a service (with "Replace selected text" activated) and run that into a Textwrangler window, I'll get fully decomposed forms that Textwrangler won't understand. But when I simply type that command into Terminal, I get my string in composed form.
    The problem is not the display issue, but the fact that if I want to run grep for example in "run shell script", I will not be able to find the proper strings since the forms are different.

    Originally I was using $@ to parse a string and get the result pasted by the service. That was a while ago. There, I noticed that some Japanese characters were messed up. Basically all the kana characters that come with voicing markers like が-ga (instead of か-ka) etc. I did not have the time to pursue that issue though.
    Then, last night, I found that a colleague of mine had tried to use $@ to feed to a local dictionary application called ding (http://ftp.tu-chemnitz.de/pub/Local/urz/ding/). His problem was with characters that had umlauts. After verifying how he wrote his action I remembered that I had similar issues with Japanese.
    Basically his command was "/path/to/ding $@"
    That's supposed to use the selected string as an argument to pass to ding, which will launch a Wish application where the string is used as the searched item.
    From Terminal, that works a treat. But the exact same line in Automator (with input as argument, not as stdin) messed the composition and the resulting string was not recognized by ding as a match to what it was supposed to match.
    So, I tried a few things to get to the core of the issue and found that a simple "echo [accented characters]" was enough to reproduce the difference in string handling between Automator and Terminal. That difference is also reproduced on a number of person's machines.
    I have a number of services that basically revolve on "run shell script" actions and involve 3rd party application outputs, preference files etc. so it would not be convenient to show that to you.
    I have sent a mail about this issue to the automator list yesterday too:
    http://lists.apple.com/archives/Automator-users/2011/Jun/msg00004.html

  • Cannot add "Run shell script" to workflow

    Just like the subject says on an iBook G4, OS X 10.4.8. The previous solution of deleting the Automator cache file in ~/Library did not work for me. The console log does show an error when I attempt to drag Run Shell Script to the workflow error:
    2006-11-25 21:15:32.909 Automator[545] * -[NSTextView replaceCharactersInRange:withString:]: nil NSString given.
    I do have an updated bash installed using DarwinPorts, however that is installed to /opt/local/bin, which appears in my path before /usr/bin. This isn't causing problems on my cube, though.
    Any ideas?

    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

Maybe you are looking for

  • Role Grants to Bounded Task Flow not Recognized on standalone WLS 10.3

    Jdeveloper 11G Build 1188 Weblogic 10.3 I receive this error oracle.adf.controller.security.AuthorizationException: ADFC-0619: Authorization check failed: '/WEB-INF/menuflow.xml#menuflow' 'VIEW'. This occurs before and after security migration. I hav

  • How can I recover accidentally deleted text messages?

    I accidentally deleted text message from a specific person in my phone.  Not sure how to recover from an earlier version of a back up?  Or if that's possible.  HELP!  I need these messages!

  • Oracle 9i Lite and JavaServer Pages (JSP)

    Hello, I was refered to this forum as I have a couple of questions: 1. If I have an application built on JSPs and Servlets that runs against Oracle 9i and Oracle 9ias, Could I run the same application on Oracle Lite without making any changes to the

  • Browser support for SAP Netweaver 7.3

    Hi All, Just wanted to know what all browsers are support by SAP Netweaver 7.3 bcoz its mentioning it supports all the major browsers but I could not find the versions of it as well as do we have to do some extra work to make it compatible with diffe

  • Procedure run order in a Package

    Are procedures run in a specific order in a package? If so, what determines that order? Thanks!