How to run a Python Script in Terminal ?

Hello,
how can you run a Python Script in Terminal ? (OS X 10.4.5 - not OS X Server)
It´s about this Sript:
http://www.macosxhints.com/article.php?story=20060225091102170
Thanks
iMac G5 20"   Mac OS X (10.4.5)  

While this isn't really specific at all to OS X Server (please keep your questions in the "Mac OS X Server" topic area related to OS X Server, it helps you and everyone else
Now then:
Please note the comments of "robg" (the site-"mom"/host):
"You'll want to save the script without the .txt extension, and remember to make it executable with chmod a+x site2template.sh
Save the file to your Desktop, and remove the ".txt" from the name so it's named: site2template.sh
then in the Terminal, issue:
chmod +x ~/Desktop/site2template.sh
"~" is shortcut for "the current user's (my) home directory"
From there you can simply use:
~/Desktop/site2template.sh /your/site
But, far better to:
choose a location to save the script, typically /usr/local/bin:
make the directory if you don't have one:
sudo mkdir /usr/local/bin
sudo cp ~/Desktop/site2template.sh /usr/local/bin/
then adjust the permissions:
sudo chmod 755 /usr/local/bin/site2template.sh
You may want to add /usr/local/bin to your path.
cat /etc/profile
and if you don't see it, add:
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
export PATH
ie:
sudo cp /etc/profile /etc/profile.bak
(back it up to play safe)
sudo pico /etc/profile
and add
:/usr/local/bin
to the path info.
Save it (ctl w)
exit (ctl x)
then type: source /etc/profile
(start learning vi or emacs eventually)
and you'll be able to run:
site2template /path\ to/your/site/to\ convert

Similar Messages

  • MacPro with10.7.3. running a Python script in terminal I see a : "There is no more application memory available on your startup disk". Python uses 10G of 16G RAM and  VM =238G with 1TB free. Log: macx-swapon FAILED - 12. It only happens with larger inputs

    On my MacPro with10.7.3. while running a Python script in terminal, after a while, in several hours actually,  I see a system message for the Terminal app: "There is no more application memory available on your startup disk". Both RAM and VM appear to be fine at this point, i.e. Python uses only 10G of 16G RAM and  VM =238G with ~1TB free. Log reads: " macx-swapon FAILED - 12" multiple times. Furthermore, other terminal windows can be opened and commands run there. It only happens with larger inputs (text files), but with inputs that are about half the size everything runs smoothly.  So the issue must be the memory indeed, but where to look for the problem/fix?

    http://liulab.dfci.harvard.edu/MACS/README.html
    Have you tried with the --diag flag for diagnostics? Or changing verbose to 3 to show debug messages? Clearly one of three things is happening;
    1. You ARE running out of disk space, but once it errors out the space is reclaimed if the output file is deleted on error. When it fails, does your output have the content generated up to the point of termination?
    2. The application (Terminal) is allocated memory that you are exceeding
    3. The task within Terminal is allocated memory that you are exceeding
    I don't know anything about what this does but is there a way to maybe run a smaller test run of it? Something that takes 10 minutes? Just to see if it works.

  • How to run the SQL Script in SQL Prompt?

    Hi ExpertGroup,
    I have written one SQL Script name called "MySQLSCript.SQL". I want to know how to run the SQL Script in SQL Prompt?.
    Generally, I run SQL Script in PL/SQL Developer tool. But In this case, some SET command is not working/supporting in PL/SQL Developer Tool.
    Let me know, How to Run in SQl Prompt.
    Thanks & Regards,
    Senthil K Kumar.

    This is my SQL Script....
    SET COLSEP '|'
    SET LINESIZE 32767
    SET PAGESIZE 50000
    /* SET LINESIZE 3000
    SET PAGESIZE 50000
    SET DEFINE OFF */
    SET ECHO OFF
    SET FEEDBACK OFF
    --SET HEADING OFF
    SET TRIMSPOOL ON
    SET NEWPAGE NONE
    SET UNDERLINE OFF
    SPOOL &&EnterPath;
    SELECT * FROM &&TableName;
    SPOOL OFF
    SET FEEDBACK ON
    --SET DEFINE ON
    PROMPT Done.
    I am able to run this script in SQL Prompt....
    Its executing fine...
    But, If I am executing again it maynot asking for new set of data....
    alternativily its taking old values only.....
    how can i exeute with new set of data in the sql prompt.....

  • How to run the open script code from eclipse?

    Hi,
    How to run the open script code from eclipse.
    Please let me any soulutions on this.

    Hi Konda
    I am not quite sure you can do that and it would even be not supported... Again, what is the purpose? Why do you want to run your openscript code in Eclipse?
    What is the code you try to run?
    As an example, even if you include al the jar files and so on. don't think the function "Launch Browser" could work because it isn't only java code orjar files.....
    If you give us more background. maybe we can guide you to a better solution...
    JB

  • How to run unix shell script from java web applet

    hi all
    i have created one java applet. my apache web server is on unix server.
    i have created one shell script in same directory where my .class and .htm files reside...
    how to run this shell script from applet? it should search this .sh file on server and not on the client browser machine...
    thanks in advance

    I suppose you could make the shell script into a CGI, configure the server to execute CGIs, and then make the applet open the URL of that CGI.

  • Run a python script from ae

    I keep getting no as an answer unfortunately but I'm asking here. I'm not talking about omino's graphics plugin, I need to use this in more of a scripting scope. As far as I've seen, his plugin does graphics related stuff.

    Run a Python script in what fashion? Just looking to launch it from within AE? You could use the execute() method for a File object to just launch it with it's default app. You might also launch via command line with the system.callSystem() method. If you're on MAC, you might even be able to intigrate it into an AppleScript to launch it as well. As far as launching/using Python directly within AE, this hasn't been possible since "Useful Things" went away.

  • How to run an Oracle Script File

    Hi,
    Please anybody tell me how to run an Oracle script file (*.sql file) from Query template.
    In SQL*Plus we run a script file as @Script_file_name.sql
    how do we do it in Query Template.

    Dave,
    Please only post your question in one thread at a time....
    [SAP xMII synchronus commincation|SAP xMII synchronus commincation]
    Sam

  • How can I use automator to open terminal change directory run a python script?

    Hi all,
    I dont really ever use automator - which may be my big problem - and I am trying to make an apllication that seems fairly simple in theroy. I want something that will lunch terminal, cd to the place where my python script lives and then run it. I have tried a number of suggested ways and can get the terminal to open and the directory to change but cant figure out how to run the script. This is my workflow if i did it manually each time
    - open terminal
    - type cd "the place where my file lives"
    - type python uploadr.py -d
    I can get terminal to open then cd to the right place but cant get the "python uploadr.py -d" to run without an error.
    any help would be very appricated
    thanks!!!
    J

    this is the script I got closest with - I know its something to do with breaking those two commands up but i just dont know how to do it
    on run {input, parameters}
              tell application "Terminal"
      activate
                        if (the (count of the window) = 0) or ¬
                                  (the busy of window 1 = true) then
                                  tell application "System Events"
      keystroke "n" using command down
                                  end tell
                        end if
                        do script "cd /Users/behole/Desktop/FlickrUpload/" & "python uploadr.py -d" in window 1
              end tell
              return input
    end run
    this is the error I get in terminal after I run it
    Last login: Mon Jul 23 15:37:17 on ttys000
    be-holes-MacBook-Pro:~ behole$ cd /Users/behole/Desktop/FlickrUpload/python uploadr.py -d
    -bash: cd: /Users/behole/Desktop/FlickrUpload/python: No such file or directory
    be-holes-MacBook-Pro:~ behole$

  • 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 a python file on Safari?

    Good day,
    I am trying to run any python file on the Leopard web server, accesing it via safari.
    also I have set the permissions of the file to 777...
    then I have copied the file to library/webserver/documents.When I open this file in Safari, the file is listed, but it is not executed.
    also I have copied the file to library/webserver/cgi-executables, but the file is not executed, an error appears:
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
    More information about this error may be available in the server error log
    the python file contains only 2 lines:
    #!/usr/bin/env python
    print 2
    I have tested the file in the command line via python test.py and it runs fine... but I dont know what should I have to do to run it on the browser...
    do I have to enable mime types for python on leopard client? how to do it?
    have a nice day

    Karl Zimmerman wrote:
    Note that the script you've given doesn't produce a valid HTML page. How your browser chooses to render '2' is undefined. However, I don't think this is the problem you're seeing right now...
    Actually, you're right, that is the problem: there's no HTTP header. The script needs this line:
    print 'Content-type: text/html
    before anything else is sent to the browser, and it will work. At least, it works with Apache 1.3 in Tiger, but I'd expect it to be the same with Apache 2.
    charlie

  • Schedule a task on window 7 command line for running a Python script

    I have a Python script.
    1. if I directly run it on the command line: python pythonscript.py it is working.
    2. I want to run it every 30 minutes, I created a schtasks like this:
    2.1 schtasks /create /tn "myTask" /tr "C:\python27\python.exe Path_to_Python_Script" /sc minute /mo 30 /st 08:03
          the schtasks itself was created successfully and I think the task was run but I did not see any result come out.
    2.2 schtasks /create /tn "myTask" /tr "python pythonscript" /sc minute /mo 30 /st 08:03 (schtasks command is on the directory of pythonscript)
       the schtasks itself was created successfully and I think the task was run but I did not see any result come out.
    2.3 schtasks /create /tn "myTask" /tr "myscript.bat" /sc minute /mo 30 /st 08:03 (schtasks command is on the directory of pythonscript and myscript.bat and in the myscript.bat, I have one line code: python pythonscript)
       the schtasks itself was created successfully and I think the task was run but I did not see any result come out.
       How if I do: Cuurent directory>myscript.bat (then enter) OR myscript(then enter), it runs and get the result.
    Question: Why the task scheduled can not have result come out?
    Thanks.

    Hello,
    The Windows Desktop Perfmon and Diagnostic tools forum is to discuss performance monitor (perfmon), resource monitor (resmon), and task manager, focusing on HOW-TO, Errors/Problems, and usage scenarios.
    Since your post is off-topic, I am moving it to the
    off topic forum.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book:
    Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • Passing arguments to and running a Python script

    I have a Python script that I am creating a Java GUI for. How can I call this python script from within Java? I need to pass three arguments to the script, each one a string. Are Jepp / Jython what I need to use? Any tips for an absolute beginner at Java / Python integration?

    Yes, after you create the PythonInterpreter, you can just call set on it and those objects are then directly accessible in the jython scripts. To run blocks of code, I've been doing something like
    //after initialize and set interpreter vars
    PyObject locals = pythonInterpreter.getLocals();
    PyCode code = Py.compile_flags(source, filename, "exec", null);
    Py.exec(code, locals, locals);Note though that this was on Jython 2.1 or 2.2 a while back, so you might have a newer version with maybe not exactly the same method calls.
    cheers, Brynjar

  • Running a python script as a step in a job

    01/08/15 Let me see if I can phrase the question a little better.
    The following is what I currently have in a batch file, it works:
    python F:\Scripts\DataManagement\DataPublication\LandBase_Structures\FeatureIDPopulator.py "GISEDITDB" "edgis""gis_admin" "gisadmin" "LandBase_Structures" "LST"
    How would I write the string if I wanted this to run as an Operating system (CmdExec) step ?  Disregard what I tried to do from my original post.
    I am not that familiar with Powershell, but would that be a better way to approach this ?
    Again, thanks !
    Disregard what I 'tried' to do below.
    I am setting up a job which runs some SQL and a python script.
    The 'type' for this step is Operating system (CmdExec).
    C:\Windows\System32\cmd.exe /C \\WDC1GISSHP1\E\Python26\ArcGIS10.0\python "Z:\python\FeatureIDPopulator.py "GISEDITDB" "edgis" "username" "password" "LandBase_Structures" "LST""
    The items in " " are parameters passed to the script.
    It errors out with '...The system cannot find the file specified'
    I just added the cmd.exe, and only that executes now, not the rest of the line.
    How can I run this script ?  Can I run this as a step using a command line format as i am trying or should it be in a batch file ?
    Thanks.

    C:\Windows\System32\cmd.exe /C \\WDC1GISSHP1\E\Python26\ArcGIS10.0\python "Z:\python\FeatureIDPopulator.py "GISEDITDB" "edgis" "username" "password" "LandBase_Structures"
    "LST""
    Hello,
    Is Z: a mapped drive in your Profile? It won't be available for a SQL Server Agent Job. And take care that the used Service account do have permissions to access the network share
    \\WDC1GISSHP1 and the mapped drive.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How to call a python script from a TestStand sequence?

    Please tell me how is it possible to call a python script from a TestStand sequence.
    Thank for your help in advance.
    Imre

    Here you can find some information about Python and LabVIEW:
    http://forums.ni.com/ni/board/message?board.id=170​&message.id=124424&query.id=149647#M124424
    If you have LabVIEW, you could use LabVIEW steps to call your Phyton Scipts.
    Another solution would be, to do, what is decriibed in the thread directly in TestStand:
    You can call a dll or .NET assemblies directly from teststand, or use the "Call Executable" TestStep.

  • How to run a sql script in oracle forms

    Hi,
    For me there is an sql script. I need to run that sql script in forms.
    Actually we will run that sql file in pl/sql developer by giving @and the file name.
    But how to run that file in forms.
    Can any one help on these.Which book I have to look.
    Thanks

    Actually there is a script files which will drop all the indexes and tables.
    DROP querry will be there for each index and each table.
    So I run the script all the indexes and all the tables will be deleted. So using forms I have to run that script.
    Thanks

Maybe you are looking for

  • MacBook Pro won't connect to wireless network unless tilted

    Hi! My MacBook Pro occasionally has trouble connecting to the wireless network in my house, but that can usually be solved by turning Airport off and then back on. Today (very suddenly), Airport disconnected from my network and could not find it agai

  • Applet java.rmi.RemoteException class not found

    Hi, my applet uses the RMI connection to server. Applet working fine with appletviewer. i try to load my applet in IE its giving class not found error. error message : java.lang.ClassNotFoundException: java.rmi.RemoteException      at com/ms/vm/loade

  • Session tracking in JSP

    hi, we have used JSP and JavaBeans in a simple employee database kindof application. each employee has a manager and some details. an employee logs into the system using his employee id and a password and performs related tasks. we are unable to main

  • Funky window in iTunes 9 with missing sides

    I am missing parts of my window in iTunes 9. I am missing the bottom of the window as well as the right hand side. The minimize, maximize and exit buttons are missing. I have to use File, Exit to close the application. Also when i try to scroll throu

  • Belgian EID in Firefox 8.0

    Dear, are there known problems using a Belgian EID card in firefox 8.0. It used to worl with FF3.6, but not anymore in 8.0 i can read my card using the BEID software for reading and i can use the EID with other browsers.