简体   繁体   中英

How can I create a shell script through a python code?

I have written a python code inside which at a certain line I want to write a file xyz.sh but its saying permission denied. I tried to use os.rename() also but it didn't work. Thanks in advance.

Since we don't know your code, we can't give an exact answer. But here are some hints:

If you are new to linux, you may want to check that if you want to use a relative path, you are not allowed to start the path with a / at the beginning.

Further we don't know which part fails (execution or writing). If execution fails check that:

Before execution your file has to be marked as executable. In the command line you could do: chmod +x xyz.sh

If you want to execute a relative path you have to start the path with a ./ at the beginning. (ie ./scriptsInMyProgramFolder/xyz.sh )

Please be a bit more precise next time. ;-)

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