Python script directory issues

I'm writing a script in python that calls a file by the function open("filename.txt"). The file is in the same folder as the script, but I keep getting Errno 2 saying that there isn't any file or directory by that name. I transferred the entire folder to a different computer, but it wouldn't run then either. I've checked with several, more knowledgable coworkers about this and they all say my code is fine, and doesn't have any errors. Does anyone know how I can get the script to recognize the file?

I'd expect to see the default directory (see the shell pwd command), and not a directory relative to the script (Python, in this case) that's been invoked.  Provide the full path to the target file within the script.  Or temporarily place the target file into the current working directory.  Or both.  See if that works.  (Depending on the context you're operating in here, there may well be other ways available, too.)

Similar Messages

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

  • Python script to parse 'iwlist scan' into a table

    Hi,
    I've written a small python script that parses the output of the command "iwlist interface scan" into a table.
    Why ?
    Like many arch linux users I think, I use netcfg instead of something like network manager or wicd. So the most natural way to scan for wifi networks in range is iwlist scan. But the output of this command is huge and I find it difficult to retrieve information. So this script parses it into a table : one network, one line.
    Example output
    Name Address Quality Channel Encryption
    wifi_1 01:23:45:67:89:AB 100 % 11 WPA v.1
    wifi_2 01:23:45:67:89:AC 76 % 11 WEP
    wifi_3 01:23:45:67:89:AD 51 % 11 Open
    wifi_4 01:23:45:67:89:AE 50 % 11 WPA v.1
    wifi_5 01:23:45:67:89:AF 43 % 4 Open
    wifi_6 01:23:45:67:89:AG 43 % 4 WPA v.1
    Details
    It reads from stdin so you use it like that: iwlist wlan0 scan | iwlistparse.py
    The width of the columns is determined by what's in it.
    You can easily do a bit more than just parsing the info: in the example above, the quality has been calculated to percents from a ratio (e.g. 46/70).
    It is sorted, too.
    Customization
    It's python so it's easy to customize. See the comments in the code.
    Code
    #!/usr/bin/env python
    # iwlistparse.py
    # Hugo Chargois - 17 jan. 2010 - v.0.1
    # Parses the output of iwlist scan into a table
    import sys
    # You can add or change the functions to parse the properties of each AP (cell)
    # below. They take one argument, the bunch of text describing one cell in iwlist
    # scan and return a property of that cell.
    def get_name(cell):
    return matching_line(cell,"ESSID:")[1:-1]
    def get_quality(cell):
    quality = matching_line(cell,"Quality=").split()[0].split('/')
    return str(int(round(float(quality[0]) / float(quality[1]) * 100))).rjust(3) + " %"
    def get_channel(cell):
    return matching_line(cell,"Channel:")
    def get_encryption(cell):
    enc=""
    if matching_line(cell,"Encryption key:") == "off":
    enc="Open"
    else:
    for line in cell:
    matching = match(line,"IE:")
    if matching!=None:
    wpa=match(matching,"WPA Version ")
    if wpa!=None:
    enc="WPA v."+wpa
    if enc=="":
    enc="WEP"
    return enc
    def get_address(cell):
    return matching_line(cell,"Address: ")
    # Here's a dictionary of rules that will be applied to the description of each
    # cell. The key will be the name of the column in the table. The value is a
    # function defined above.
    rules={"Name":get_name,
    "Quality":get_quality,
    "Channel":get_channel,
    "Encryption":get_encryption,
    "Address":get_address,
    # Here you can choose the way of sorting the table. sortby should be a key of
    # the dictionary rules.
    def sort_cells(cells):
    sortby = "Quality"
    reverse = True
    cells.sort(None, lambda el:el[sortby], reverse)
    # You can choose which columns to display here, and most importantly in what order. Of
    # course, they must exist as keys in the dict rules.
    columns=["Name","Address","Quality","Channel","Encryption"]
    # Below here goes the boring stuff. You shouldn't have to edit anything below
    # this point
    def matching_line(lines, keyword):
    """Returns the first matching line in a list of lines. See match()"""
    for line in lines:
    matching=match(line,keyword)
    if matching!=None:
    return matching
    return None
    def match(line,keyword):
    """If the first part of line (modulo blanks) matches keyword,
    returns the end of that line. Otherwise returns None"""
    line=line.lstrip()
    length=len(keyword)
    if line[:length] == keyword:
    return line[length:]
    else:
    return None
    def parse_cell(cell):
    """Applies the rules to the bunch of text describing a cell and returns the
    corresponding dictionary"""
    parsed_cell={}
    for key in rules:
    rule=rules[key]
    parsed_cell.update({key:rule(cell)})
    return parsed_cell
    def print_table(table):
    widths=map(max,map(lambda l:map(len,l),zip(*table))) #functional magic
    justified_table = []
    for line in table:
    justified_line=[]
    for i,el in enumerate(line):
    justified_line.append(el.ljust(widths[i]+2))
    justified_table.append(justified_line)
    for line in justified_table:
    for el in line:
    print el,
    print
    def print_cells(cells):
    table=[columns]
    for cell in cells:
    cell_properties=[]
    for column in columns:
    cell_properties.append(cell[column])
    table.append(cell_properties)
    print_table(table)
    def main():
    """Pretty prints the output of iwlist scan into a table"""
    cells=[[]]
    parsed_cells=[]
    for line in sys.stdin:
    cell_line = match(line,"Cell ")
    if cell_line != None:
    cells.append([])
    line = cell_line[-27:]
    cells[-1].append(line.rstrip())
    cells=cells[1:]
    for cell in cells:
    parsed_cells.append(parse_cell(cell))
    sort_cells(parsed_cells)
    print_cells(parsed_cells)
    main()
    I hope you find it useful. Please report bugs, I haven't tested it a lot. You may have to customize it though, because I think not all iwlist scan outputs are the same. Again, see comments, it should be easy.

    This tool is very helpfull. I am trying to add a new function to the existing code to parse the signal level parameter from the output of iwlist wlan0 scan, but I am getting lot of issues .Since I am new to python script can anyone help me to extract the signal level also from the scan put put.
    The parametr to be used is Signal level=-44 dBm ,I am trying to create a one more column with Signal level and print its out in the table.
    Example:-
    Signal level
    -44db
    The error I am getting
      File "iwlist_parser_Testing.py", line 146, in <module>
        main()
      File "iwlist_parser_Testing.py", line 144, in main
        print_cells(parsed_cells)
      File "iwlist_parser_Testing.py", line 123, in print_cells
        print_table(table)
      File "iwlist_parser_Testing.py", line 102, in print_table
        widths=map(max,map(lambda l:map(len,l),zip(*table))) #functional magic
      File "iwlist_parser_Testing.py", line 102, in <lambda>
        widths=map(max,map(lambda l:map(len,l),zip(*table))) #functional magic
    TypeError: object of type 'NoneType' has no len()
    Could some pls help me to solve this issue
    Thanks

  • Include python script inside an app

    Hi all, I'm writing an applescript app which should use a python script.
    how can I include the script inside the apple and have it called by the applescript?
    Thank you!

    Now, is there a way to let the user choose both the output file directory and the output file name (out.iso)?
    To get the filename, add this after the code to select the directory:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #E6E6EE;
    overflow: auto;">
    set outPutName to text returned of (display dialog "Now, please enter a filename:" default answer "out" with title "Enter Filename") & ".iso"</pre>
    But you need to remove "quoted form of the" from dirOutput.
    Also, "set dirOutput to POSIX path of the dirOut" is not needed.
    so, this should work:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #E6E6EE;
    overflow: auto;">
    set dirOut to (POSIX path of (choose folder with prompt "Scegli la posizione in cui salvare il file convertito"))
    set outPutName to text returned of (display dialog "Now, please enter a filename:" default answer "out" with title "Enter Filename") & ".iso"
    if outPutName is ".iso" then set outPutName to "out.iso" -- simple error check for blank name
    if outPutName contains "/" then set outPutName to "out.iso" -- simple error check for bad charater in name
    set fullPathOut to quoted form of (dirOut & outPutName)
    </pre>
    Tony

  • SP1 for Exchange 2013 install fails with ECP virtual directory issues and now transport service won't start and mail is unavailable

    SP1 for Exchange 2013 install failed on me with ECP virtual directory issues:
    Error:
    The following error was generated when "$error.Clear();
              $BEVdirIdentity = $RoleNetBIOSName + "\ecp (name)";
              $be = get-EcpVirtualDirectory -ShowMailboxVirtualDirectories -Identity $BEVdirIdentity -DomainController $RoleDomainController -ErrorAction SilentlyContinue;
              if ($be -eq $null)
              new-EcpVirtualDirectory -Role Mailbox -WebSiteName "name" -DomainController $RoleDomainController;
              set-EcpVirtualdirectory -Identity $BEVdirIdentity -FormsAuthentication:$false -WindowsAuthentication:$true;
              set-EcpVirtualdirectory -Identity $BEVdirIdentity -InternalUrl $null -ExternalUrl $null;
              . "$RoleInstallPath\Scripts\Update-AppPoolManagedFrameworkVersion.ps1" -AppPoolName:"MSExchangeECPAppPool" -Version:"v4.0";
            " was run: "The virtual directory 'ecp' already exists under 'server/name'.
    Parameter name: VirtualDirectoryName".
    Error:
    The following error was generated when "$error.Clear();
              $BEVdirIdentity = $RoleNetBIOSName + "\ECP (name)";
              $be = get-EcpVirtualDirectory -ShowMailboxVirtualDirectories -Identity $BEVdirIdentity -DomainController $RoleDomainController -ErrorAction SilentlyContinue;
              if ($be -eq $null)
              new-EcpVirtualDirectory -Role Mailbox -WebSiteName "name" -DomainController $RoleDomainController;
              set-EcpVirtualdirectory -Identity $BEVdirIdentity -FormsAuthentication:$false -WindowsAuthentication:$true;
              set-EcpVirtualdirectory -Identity $BEVdirIdentity -InternalUrl $null -ExternalUrl $null;
              . "$RoleInstallPath\Scripts\Update-AppPoolManagedFrameworkVersion.ps1" -AppPoolName:"MSExchangeECPAppPool" -Version:"v4.0";
            " was run: "The operation couldn't be performed because object 'server\ECP (name)' couldn't be found on 'DC0xx.domain.com'.".
    Error:
    The following error was generated when "$error.Clear();
              $BEVdirIdentity = $RoleNetBIOSName + "\ECP (name)";
              $be = get-EcpVirtualDirectory -ShowMailboxVirtualDirectories -Identity $BEVdirIdentity -DomainController $RoleDomainController -ErrorAction SilentlyContinue;
              if ($be -eq $null)
              new-EcpVirtualDirectory -Role Mailbox -WebSiteName "name" -DomainController $RoleDomainController;
              set-EcpVirtualdirectory -Identity $BEVdirIdentity -FormsAuthentication:$false -WindowsAuthentication:$true;
              set-EcpVirtualdirectory -Identity $BEVdirIdentity -InternalUrl $null -ExternalUrl $null;
              . "$RoleInstallPath\Scripts\Update-AppPoolManagedFrameworkVersion.ps1" -AppPoolName:"MSExchangeECPAppPool" -Version:"v4.0";
            " was run: "The operation couldn't be performed because object 'server\ECP (name)' couldn't be found on 'DC0xx.domain.com'.".
    !! And now transport service won't start and mail is unavailable !!
    Any help would be appreciated.
    I have removed the ecp site from default site and attempting to rerun SP1 now. I do not have high hopes. :(

    Hi,
    Thanks for your response.
    From the error description, you need to manually remove the ECP with IIS manager in both the Default Web Site and the Exchange Back End firstly. And then continue the upgrade to check the result.
    Hope this can be helpful to you.
    Best regards,
    Amy Wang
    TechNet Community Support

  • What is correct way to run python script in build phases

    in xcode 4.6  build phases i have added a run script
        python build.py
        exit
    when i build project it never finishes it keep on saying running custom shell script
    what is correct way to run python script in build phases ?

    /usr/bin/python build.py
    exit
    still the issue remians.

  • Merge Python Script

    Does anyone have any ideas about creating a Python script to merge some pdfs and possibly sign the finished document? I've looked at pyPdf.pdf a little. Not sure if this is the best way to go or not. Just need help getting started. Examples might be helpful.
    I'm leery of JavaSciprt b/c of security issues.
    Any advice, comments or criticisms are welcome.
    Thanks!

    Adobe has addressed all of those issues.
    Users need to apply update their products and update their products.
    Acrobat X has a sandbox feature that really restricts Acrobat/Reader from the OS.

  • Pacexp - python script to list REALLY explicitly installed packages

    I usually just lurk the forums-- well, except for when I'm here asking for help with some PEBKAC issues... but never mind that.
    This is a small python script I just wrote today while procrastinating. I'd love some feedback on the code, personally, but I'm hoping this could be useful to someone else. I always forget the stuff I have installed when I'm looking to clean my system up and `pacman -Qe` lists a lot of packages that Arch installs itself, so this is my way of dealing with it.
    I'll probably be adding some other features to this script anyway, I'm gonna try to keep this post updated whenever I do so.
    pacexp
    A quick and dirty script to intersect the output of `pacman -Qe` with manually installed packages from /var/log/pacman.log
    https://gist.github.com/spaceporn/d4ec6391a4684efb933c
    If anyone has any suggestions to improve the code (even a better regexp counts), feel free to write them down here or on the gist page!

    karol wrote:
    I use
    expac "%n %N" $(comm -23 <(pacman -Qq|sort) <(pacman -Qqg base base-devel|sort)) | awk '$2 == ""' | less;
    to list packages that aren't required by any other package and are not part of base or base-devel. All of them have been explicitly installed.
    That's pretty cool! I'll probably save it as an alias if I ever have problems with my script

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

  • Open a python script containing bundle... problems!

    I'm not sure how to extract the bundle from this python script. I won't go into much detail, but you can look at this example project I found that can replace InstallerPluginSample with python to create a bundle file. Your help will be much appreciated
    http://pyobjc.sourceforge.net/examples/pyobjc-framework-InstallerPlugins/Install erPluginSample/index.html

    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$

  • 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$_"}})

  • Running python script with system arguments from applescript

    Hi,
    I am trying to run a python code from within applescript. A string should be passed as an argument to the python script, i.e. from the terminal, I would do the following
    cd /Users/thatsme/Library/Scripts/myfolder
    python my_python_file.py abcdefg
    There are two ways I figure I could do this in applescript. "abcdefg" are contained in the variable strNote
    a) directly:
    do shell script "cd /Users/thatsme/Library/Scripts/myfolder; python my_python_file.py " & strNote
    b) calling Terminal
    tell application "Terminal"
      activate
              do script "cd /Users/claushaslauer/Library/Scripts/OO_latex; python my_python_file.py " & strNote
    end tell
    I would prefer option a) as I don't really want to have Terminal windows popping up. The strange thing is, that I see in the applescript results window the result of the print statements in the python script, but no output is generated (the python script contains a few os.system() commands.
    Option b) does what it is supposed to be doing, however, applescript does not wait until the script is finished running.
    Why does option a) nor work, and what do I need to change to make it work?

    Thank you guys for your help, this is really weird.
    Here is my full applescript
    set strNoteQ to "1+1=2"
    (* for whatever reason, this does not work *)
    do shell script "cd /Users/claushaslauer/Library/Scripts/OO_latex; python create_latex_pdf.py " & strNoteQ
    Below is my python skript.
    When I call it as
         python create_latex_pdf.py 1+1=2
    it creates a wonderful pdf.
    With the applescript above, it prints the print statements, it also generates the latex file temp.tex -- correctly, so I assume the string in this example is ok.
    However, it does not execute the latex related commands (the three os.system calls)
    Is it not a good idea / not possible to execute os.system in a python script that is called from applescript? <sorry if I had brought all the attention to the string issue>
    here is the python script:
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    import sys
    import os
    import datetime
    import time
    def main():
        str_latex_note = sys.argv[1]
        print "%s" %  str_latex_note
        preamble = """\documentclass{article}
    \usepackage{amsmath,amssymb}
    \pagestyle{empty}
    \\begin{document}
    {\huge
    %s
    \end{document}"""% (str_latex_note)
        ## write latex file
        cur_path = r'/Users/mypath/Library/Scripts/OO_latex'
        cur_file = "temp.tex"
        fobj = open(os.path.join(cur_path, cur_file), 'w')
        fobj.writelines(preamble)
        fobj.close()
        ## process latex file
        print cur_path
        os.chdir(cur_path)
        cmd = 'latex temp.tex'
        print cmd
        print "running latex"
        os.system(cmd)
        cmd2 = 'dvips -E -f -X 1200 -Y 1200 temp.dvi > temp.ps'
        print "running dvips"
        os.system(cmd2)
        cmd3 = 'epstopdf temp.ps'
        print "running epstopdf"
        os.system(cmd3)
        print "done!"
    if __name__ == '__main__':
        main()

  • Scripting modifications to LDAP inside Python script

    Hi all,
    I have written Python scripts to create redundant print services on two OS X Server 10.6 machines running print services for al hundred or so macs in computer labs. The Mac printing (which printers appear to users) is managed via MCX w/OD. Essentially how they work is this:
    *script periodically tests socket connectivity on primary server IPP/LPR ports
    *on failure script does command to start Print Service on backup print server
    *script then does command on OD LDAP to import mcx settings for backup print server to all applicable managed clients
    The commands are done with "Popen" so they are shell commands. To modify the LDAP directory, I would use the Popen equivalent of "/usr/bin/dscl -u <diradmin user> -P <diradmin pwd> /LDAPv3/127.0.0.1 -mcximport /<managed client path> <path to mcx settings>"
    It would be much nicer to not have the auth info hardcoded into the script. I've tried logging in to a shell on the server under the diradmin credentials and running the python script, but get permission denied when trying to modify LDAP. I also tried giving a test user account "full" privileges in WGM to modify directory and running script logged into a shell as this user, with the same failure.
    I may be missing something totally obvious, but I am coming up blank..
    Is there any way to script modification to the LDAP directory without supplying credentials in the script?

    Hi all,
    I have written Python scripts to create redundant print services on two OS X Server 10.6 machines running print services for al hundred or so macs in computer labs. The Mac printing (which printers appear to users) is managed via MCX w/OD. Essentially how they work is this:
    *script periodically tests socket connectivity on primary server IPP/LPR ports
    *on failure script does command to start Print Service on backup print server
    *script then does command on OD LDAP to import mcx settings for backup print server to all applicable managed clients
    The commands are done with "Popen" so they are shell commands. To modify the LDAP directory, I would use the Popen equivalent of "/usr/bin/dscl -u <diradmin user> -P <diradmin pwd> /LDAPv3/127.0.0.1 -mcximport /<managed client path> <path to mcx settings>"
    It would be much nicer to not have the auth info hardcoded into the script. I've tried logging in to a shell on the server under the diradmin credentials and running the python script, but get permission denied when trying to modify LDAP. I also tried giving a test user account "full" privileges in WGM to modify directory and running script logged into a shell as this user, with the same failure.
    I may be missing something totally obvious, but I am coming up blank..
    Is there any way to script modification to the LDAP directory without supplying credentials in the script?

  • Running Python Scripts through Labwindows/CVI

    Hello,
    I'm trying to execute Python scripts through Labwindows/CVI.  I believe I have the correct library for the code to access in my project. I'm getting errors as it can't find "io.h", "stat.h", or "wchar.h" files.  There is another post on this, where a modified pyconfig.h file was provided, however that file does not work for me.  I'm not sure how to obtain the correct files for what I need here.  Is there any dependable method to do this?
    I'm on Windows 7, I'm running CVI version 9.1.1 and Python 2.6.6 (32-bit).  The library file I'm using was proveded as part of the python install, called "Python26.lib".  I zipped and attached the project, but to get it working you have to download Python (http://www.python.org/download/releases/2.6.6/), and point CVI to the "Python.h" header file (in the "include" directory under the "Python26" directory.
    Attachments:
    Test project.zip ‏4 KB

    Where are these .h files located? If you know where these files are located go to Options>>Environment...>>Include Paths... you can add directories that the workspace will look for include files that are not explicitly included in your project.
    Ian M.
    National Instruments

Maybe you are looking for