简体   繁体   中英

Call alias using a Python Script

I'm writing a python script that utilizes Ureka (a distribution of different astronomy packages). In order to run any Ureka's packages, the user must first initialize Ureka by typing "ur_setup" in the terminal. It turns out "ur_setup" is an alias for the following command:

'eval `/Users/rem/.ureka/ur_setup -csh \!*`'

How would I be able to include this in my python script and have it work? Thanks in advance!

使用os.execv如果你需要接管运行过程中使用其他

I don't know about ureka, but for running any expression or command using python, you can certainly use the os module.

    import os
    os.system('eval `/Users/rem/.ureka/ur_setup -csh \!*`')

This Should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM