Unix functions in a Python script

Discussion in 'OT Technology' started by vipergts24, Apr 20, 2008.

  1. vipergts24

    vipergts24 New Member

    Joined:
    Mar 10, 2005
    Messages:
    223
    Likes Received:
    0
    Location:
    Zomgland
    Hey all, pretty new to Python (currently learning) but I need my script to run a unix function nanosleep(). How exactly do I get my script to recognize and run this function?

    Thanks
     
  2. vipergts24

    vipergts24 New Member

    Joined:
    Mar 10, 2005
    Messages:
    223
    Likes Received:
    0
    Location:
    Zomgland
    so i've come up with

    use subprocess module
    from subprocess module import call
    call['nanosleep','500']

    but I get a syntax error (doesn't appear to recognize subprocess module) anyone have any ideas?
     
  3. FartLighter

    FartLighter Resident Fart Expert OT Supporter

    Joined:
    Jul 5, 2005
    Messages:
    2,853
    Likes Received:
    9
    Location:
    Mammoth Lakes, CA
    I have used os.popen() but I do not know if that is the proper way to do it. It has seemed to work for me...
     
  4. vipergts24

    vipergts24 New Member

    Joined:
    Mar 10, 2005
    Messages:
    223
    Likes Received:
    0
    Location:
    Zomgland
    I've come to that conclusion as well from talking to another source. I'll try to read more about it and use it.
     
  5. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    God damn Python is confusing.
     
  6. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    It's one of the more worthless scripting languages, that's for sure. It's a damn shame *nix doesn't support VBScript.
     
  7. piratepenguin

    piratepenguin New Member

    Joined:
    Jun 18, 2006
    Messages:
    1,067
    Likes Received:
    0
    Location:
    Ireland
    what is so good about VBScript.
     
  8. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    It's perhaps the most heavily-developed scripting language ever. It's definitely on-par with JavaScript. Pretty much everything else was either designed for a niche market, or just lacked the wide base of support needed to become a mainstay.
     
  9. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    rofl

    I know, and those MORONS at Google like it for some reason. :rofl: If they had any sense, they'd be using... VBScript.
     
  10. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Why are you comparing Javascript, VBScript with... Python? Python is a dynamic OO language of great power. The other two are not.
     
  11. GOGZILLA

    GOGZILLA Double-Uranium Member

    Joined:
    Jan 16, 2003
    Messages:
    10,760
    Likes Received:
    3
    Location:
    Plantation, FL
    1. someone makes post
    2. deus posts something relevant to topic but usually wrong
    3. someone who does know something about the topic replies usually disagreeing with dues
    4. people who dont feel need to post on everything, especially things they dont know about LOL
    5. deus tries to argue himself out of the hole by digging it deeper
     
  12. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
  13. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    Odd. ArcGIS uses Python and VBScript. AutoCAD uses LISP and VBScript. All Microsoft products use VBScript.

    I've yet to see VBScript added as a script language to a popular product without seeing all other available languages abandoned by programmers in a metter of months.

    One language that you can use to build tools for all the apps your company uses > *. It's the same reason C-based languages are so popular for native compiled code; once you learn one, you know them all, more or less.
     
  14. Nocera

    Nocera ...

    Joined:
    Aug 9, 2000
    Messages:
    1,307
    Likes Received:
    0
    Location:
    Long Island, NY
    If you're trying to suspend execution of the script itself, just use:

    Code:
    import time
    time.sleep(1) # sleep for 1 second
    
     

Share This Page