w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
php create_directory Permission denied: when attempting shell_exec script
Are you trying to execute script at /home/user/scripts/./script then you should run as shell_exec('sh /home/user/scripts/script') When you add ./ there on path its interpreted differently. When you pass ./script - You are referring to filename script in current directory. Also you are actually getting error from your c program which tells us your system is stopping apache to gain root privileges. You can audit2allow to let apache gain needed privileges.

Categories : PHP

OSError: [Errno 13] Permission denied in Python script when passing files > 1 Kb
you don't have permission to open (or write?) whatever file you are trying to work with. Try running the script as super user or change permissions on the directory where you are trying to read/write from

Categories : Python

Invoke python script from another python script and set execution directory of the executed script
You could use cwd parameter, to run scriptB in its directory: import os from subprocess import check_call check_call([scriptB], cwd=os.path.dirname(scriptB))

Categories : Python

./script.sh: line 8: /etc/passwd: Permission denied
You're trying to execute /etc/passwd and send the output to cut. You want to redirect the contents of the file: for user in `cut -f 1 -d : < $USERS`

Categories : Bash

Permission denied to access the file from php script
After setting the permission execute in following manner will solve the problem: $a=exec('/home/technoworld/Videos/LinSocket/client "critic good"'); client is the executable file that I wanted to execute and "critic good" is argument to be passed!

Categories : PHP

how to pass variable from python to shell script when shell script is getting called inside python script
You can: Step through the list, and then call mail.sh once for each file. This is the most reliable way. Convert the items in the list to a space delimited string, and then pass it in to mail.sh (assuming mail.sh is setup correctly, it should accept multiple arguments). What you cannot do is pass ['a.txt','b.txt','c.txt'] wholesale to the script.

Categories : Python

On Mac, how to create a drag & drop app for a python script where the script name rather than Python shows in the MenuBar (etc.)?
I have an answer to my question, but I am hoping that someone can come up with something less complex. The solution I came up with was a Python script to create an AppleScript (ugh!), compile it into a bundle and then modify the bundle to change the allowed file extension(s), the icon and so on. I did not find a way to get drag-and-drop working when starting a wxpython script, without an AppleScript (or using py2app) and I could not get the AppleScript to work in a bundle I created, I had to use osacompile to create the bundle for me. I like better the approach here or here, where one creates the plist file "by hand" rather than than modify an externally created one as I do here, but the script below does do the job. #!/usr/bin/env python '''This script creates an AppleScript app to

Categories : Python

Script giving error of permission denied OSerror 13 from cronjob?
The error means that the program is found by subprocess but the user running the "nessusscan.py" does not have permissions to run it. Check ownership of the nessus file and the permissions on it.

Categories : Python

Prompt for `sudo` only if Bash script runs into "Permission denied"
I don't know of any ways to categorize ln exit reasons, or at least any documentation about specific exit codes you could test with $?, but you can test for relevant permissions with the standard test or [ command: SOURCEFILE="/opt/myapp" DESTDIR="${1}" DESTTARGET="${DESTDIR}/myapp" if [ ! -d "$DESTDIR" -o ! -e "$SOURCEFILE" ]; then echo "Source file does not exist or destination directory does not exist." >&2 elif [ ! -r "$SOURCEFILE" -o ! -w "$DESTDIR" ]; then echo "Source file is not readable or destination directory is not writable." >&2 # Run sudo command here else # Should work, run command here fi

Categories : Bash

IOError: [Errno 13] Permission denied: Bulk renaming script
I am assuming that d: is not a CD drive or something not writable. If so then have you checked the properties of your files? Are any of them read only? There would also need to be more than one of the file type in the folder to cause this, I believe.

Categories : Python

Jenkins runs imported python script before main python script
The child process flushes its output buffers on exit but the prints from the parent are still in the parent's buffer. The solution is to flush the parent buffers before running the child: print("Starting script...") sys.stdout.flush() build.run()

Categories : Python

Permission denied (publickey), when cloning bitbucket repository via ruby-script
Okay, after days I found the solution my self. Due to missconfiguration, my rails app was not running as www-data user. For testing purposes I added the ssh-key of the User which actually runs the script to my bitbucket repository and it worked.

Categories : Ruby On Rails

how to call a python script inside another python script where both in the same directory?
In script1.py place this: def main(): do something if __name__ == "__main__": main() In script2.py: import script1 if condition: script1.main()

Categories : Python

dd command PERMISSION DENIED Python
I know I have to do some kind of root thing? Indeed you do! If you are using linux, sudo is the idiomatic way to escalate your user's privilege. So instead invoke 'sudo dd if=/dev/sdb of=/dev/null' (for example). If your script must be noninteractive, consider adding something like admin ALL = NOPASSWD: ALL to your sudoers, or something similar.

Categories : Python

Python FTPLIB error 530 Permission Denied
It seems like the ftp server allows anonymous access; You don't need pass username, password. FTP constructor accept hostname(or IP), not URL. import sys import os from ftplib import FTP ftp = FTP("ftpsite.com") ftp.login() ftp.cwd("/ftp/site/directory/") listing = [] ftp.retrlines("LIST", listing.append) words = listing[0].split(None, 8) filesize = int(words[4]) filename = words[-1].lstrip() class VerboseWriter: def __init__(self, lf, filesize): self.progress = 0 self.lf = lf self.filesize = filesize def write(self, data): self.lf.write(data) self.progress += len(data) sys.stdout.write(' {}/{} ({:.1%})'.format(self.progress, self.filesize, float(self.progress)/self.filesize)) sys.stdout.flush() #download the file wit

Categories : Python

PermissionError: [Errno 13] Permission denied Python
Try changing the port to 8080. You didn't say which OS, but most UNIX derivatives will only allow root to listen on ports below 1,024 or 4,096 depending on the OS and its configuration.

Categories : Python

Permission denied error while writing to a file in Python
To answer your first question: yes, if the file is not there Python will create it. Secondly, the user (yourself) running the python script doesn't have write privileges to create a file in the directory.

Categories : Python

sys module giving different output when running Python script through IDLE and by double-clicking the script
print os.path.dirname(sys.executable) is what you should use. When you click it it is probably running through python.exe so you are removing the extra char from the w.

Categories : Python

dump files from bash script in different directory from where python script ran it
You should change directory within the same command: cmd = "/path/to/executable/executable" outputdir = "/path/to/output/" subprocess.call("cd {} && {}".format(outputdir, cmd), shell=True)

Categories : Python

How do scan a script for return values from a upper script in python?
Don't invoke a Python script from a Python script by using system, which spawns a whole other interpreter. Just import it. Like this: import ToBuildOrNot needsBuild = ToBuildOrNot.run() # or whatever you call your top-level function Since ToBuildOrNot.py is a script now, make sure the "main" function is protected so it doesn't execute automatically on import. Most people do it this way in Python: What does <if __name__=="__main__":> do?

Categories : Python

Cron not running Python script is script not in home folder
cron is running crontab(5) entries from the home directory of the user. You need to change appropriately the directory i.e. to call the chdir(2) syscall (either thru the cd shell builtin, or inside your python script using os.chdir). You should query the current directory (using getcwd(3), or the pwd command, or the os.getcwd in Python) in your script. Also check your PATH if running commands.

Categories : Python

Redirect output of a .bat file run by a python script to GUI, and making that script into EXE
You could use the subprocess module to call your script Example calling the 'ls' command on Linux: >>> from subprocess import call >>> call(['ls', '-l']) total 0 -rw-rw-r-- 1 user group 0 Jun 17 18:37 file1 -rw-rw-r-- 1 user group 0 Jun 17 18:37 file2 -rw-rw-r-- 1 user group 0 Jun 17 18:37 file3 0

Categories : Python

ImportError when calling python script via a shell script
I had a similar problem. It turned out that in my bash script I was running the Python script with a different version of Python than I was on the command line (my env was set up with virtualenv on Python 2.7 but I was calling the script with Python3 from the bash script). There is nothing in your snippets indicating this is the case but it is worth checking to make sure that the Python versions match up.

Categories : Python

How run a Python script from another script and get resulting global dict?
Importing a module executes the code at the top level, and that module's "global" namespace gets imported as the name of the module james@bodacious:~$cat test.py def func(): pass myname = "michael caine" print "hello, %s" % myname james@bodacious:~$python Python 2.7.5 (default, Jul 12 2013, 18:42:21) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import test hello, michael caine >>> dir(test) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'func', 'myname'] >>> if the code you want to be run is at the top level of the file, just importing the module will execute the code and give you access to its "global" namespace all in one convenient package.

Categories : Python

error with global name when running a script from another script - python
This is a pretty interesting problem. First a quick workaround, you can provide dictionaries to use as the local and global namespace when calling execfile(), using an empty dictionary for globals works fine: # test_fun1.py a = 1 def test1(): print a execfile('test_fun2.py', {}) test1() Alternatively, if you want the code to execute within the global scope of your module you can use globals() instead of {}. Now on to why this isn't working... from the documentation on execfile(): If both dictionaries are omitted, the expression is executed in the environment where execfile() is called. Here "both dictionaries" is referring to the optional globals and locals arguments to execfile(). In this case "the environment where execfile() is called" is the local scope of the fun

Categories : Python

How to return a value from a shell script in a python script
use Subprocess.check_output instead of Subprocess.call. Subprocess.call returns return code of that script. Subprocess.check_output returns byte stream of script output. Subprocess.check_output on python 3.3 doc site

Categories : Python

Conversion of shell script to python script
It looks like you're after a templating engine, but if you wanted a straight forward, no thrills, built into the standard library, here's an example using string.Template: from string import Template with open('a.html') as fin: template = Template(fin.read()) print template.substitute(name='Bob') # <head>Bob</head> I thoroughly recommend you read the docs especially regarding escaping identifier names and using safe_substitute and such...

Categories : Python

When running Python's pdb as a script, how do I autostart the script?
that's probably not the way to do to it. you should modify/extend the existing pdb.py. the code looks like this: while True: try: pdb._runscript(mainpyfile) if pdb._user_requested_quit: break print "The program finished and will be restarted" except: traceback.print_exc() print "Uncaught exception. Entering post mortem debugging" print "Running 'cont' or 'step' will restart the program" t = sys.exc_info()[2] pdb.interaction(None, t) print "Post mortem debugger finished. The "+mainpyfile+" will be restarted" it looks like you could replace `pdb._runscript(mainpyfile)' with something like runpy.run_module(sys.argv[0], run_name="__main__", alter_sys=True) (from PEP 338). not a complete solutio

Categories : Python

How to get a python script to listen for inputs from another script
I would use a socket connection. Essentially you are writing a very simple server that only takes one connection at a time import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(("localhost", 9988)) s.listen(1) while True: conn, addr = s.accept() data = conn.recv(1024) conn.close() my_function_that_handles_data(data) s.accept() is a blocking call. It waits for a connection. Then you do a read on the connection. In this case we are assuming the length of the parameters are only 1024 bytes. Then we do something with the data we received from the socket and wait for another connection. The client could look like this: import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("localhost", 9988)) s.sendall('My parameters that I wan

Categories : Python

Call a python script in a python script
Escape backslash () "C:\temp\hello2.py" or use raw string r"C: emphello2.py" >>> print "C: emphello2.py" C: emphello2.py >>> print "C:\temp\hello2.py" C: emphello2.py >>> print r"C: emphello2.py" C: emphello2.py

Categories : Python

How can I call a python script from a python script
1: why I don't see any prints out from 'b.py' and when I do 'ps -efW' I don't see a process named 'b.py'? Change run_b lines: p = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr) You will not see a process named "b.py" but something like "python b.py" which is little different. You should use pid instead of name to find it (in your code "p.pid" has the pid). 2: Why when I kill a process like above, I see 'permission declined'? os.kill is supported under Windows only 2.7+ and acts a little bit different than posix version. However you can use "p.pid". Best way to kill a process in a cross platform way is: if platform.system() == "Windows" : subprocess.Popen("taskkill /F /T /PID %i" % p.pid , shell=True) else : os.killpg( p.

Categories : Python

python doesn't run script with 'python