w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
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

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

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

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

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

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

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

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

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

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

unable to access variable declared in ksh script to csh script using shell script
The ksh script is not doing what you think it is doing when used by ksh; it sets $1 first to MyUser=root and then MyPassword=shroot. However, when you source it from your C shell script, because the syntax is compatible with C shell (checked with tcsh), you would set the two variables. If you sourced the script from a Bourne-shell derivative, the exit at the end of the ksh script would cause the shell to exit; it does not seem to cause the C shell to exit. So, what you've got is a weird hybrid. Normally, you stick to one language and use it exclusively. Where you need to use another shell, you can do so, but you simply run the script written for the other shell. You can communicate to the other script with environment variables. You don't normally try writing sourceable code that ca

Categories : Shell

Translating shell script into Windows command shell script (batch)
for /L makes a count-controlled loop in batch. mkdir remains mkdir. @echo off for /L %%y in (1,1,9) do mkdir week_0%%y mkdir week_10

Categories : Shell

adb shell permission denied samsung s I9003
Check Run adb shell and how to get # instead of $ for root permission : Android. Hope this helps.

Categories : Android

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

The DB2 SQL script is hanging in shell script, but working successfully in command line
Are you sure DB2 is blocking? Did you put a semicolon between commands db2 CONNECT TO ktest4 ; db2 -v -f /tmp/sql/application_system/opmdb2_privilege_remove.sql.5342 In order to trace the execution, I advise you to put some output, in order to detect where is it blocking date ; db2 -r /tmp/output.log CONNECT TO ktest4 ; db2 -r /tmp/output.log values current timestamp ; db2 -r /tmp/output.log -v -f /tmp/sql/application_system ; db2 -r /tmp/output.log values current timestamp ; db2 -r /tmp/output.log terminate With a command like this, you will save all outputs, and then you could check where is the error.

Categories : SQL

bash shell script error works on command line, not in script
Variables are supposed to contain data, and bash treats them as data. This means that shell meta-characters like quotes are also treated as data. See this article for a complete discussion on the topic. The short answer is to use arrays instead: ASCIIDOC_OPTS=( --asciidoc-opts='-a lang=en -v -b docbook -d book' ) DBLATEX_OPTS=( --dblatex-opts='-V -T db2latex' ) cmd=(a2x -v -f pdf -L "${ASCIIDOC_OPTS[@]}" "${DBLATEX_OPTS[@]}" "$1".asciidoc) # Print command in pastable format: printf '%q ' "${cmd[@]}" printf ' ' # Execute it "${cmd[@]}" Make sure not to use eval: eval "$cmd" #noooo This will appear to work with your code as you posted it, but has caveats and security problems.

Categories : Bash

Source in shell script doesn't work when script called with arguments
With your script, you are automating the following commands, if xilinx ise is typed in from the command line: $ cd /home/sclukey/Xilinx $ source /opt/Xilinx/14.6/ISE_DS/settings32.sh $ ise The response from the script indicates that there's no ise program in the path. I would check to see where ise is, and if settings32.sh sets up a path for it.

Categories : Bash

How to capture the exit code of a shell script in a perl script?
You can check the exit code of another process with the child error variable $?. For example: system("perl foo.pl"); my $exit_val = $? >> 8; # now contains the exit value of the perl script Read the documentation for more info.

Categories : Perl

Combine shell script and data files into one runnable script?
Here you go: curl http://stacked-crooked.com/sh -d 'echo H4sIABq0uFEAA+3VvW6DMBSG4cy+ihOyJFICx4TYQ6rOvQ0CJBBRXPHTWqp67zVFyUgn6I++ZzlCWLI9vGD9fDE1ZlZRRP3USn9NDofnQbgnGcqDkntWShJLqZgXxJOfzOmaNq7dUa6X2oytc8vO55H3w03oPv+IVVElZZdm9NC0aWH8/FH89JFgRtZPJt/j2/5d87f+dch9/wct0f8c7v171s898RwX1XpD7+Kla5u195SVpdnSm6nLdOltjuIDX4f/pe6qyffou9d6pP9I3/qXUkd9/zqM0P8cVsvgVFTBKW5y0WQt7bJXK8QlSWhnyJL7PQg/sKgeAAAAAAAAAAAAAAAAAOC3+wQXspMdACgAAA== | base64 --decode | tar -xzv && ./run'

Categories : Bash

Retrieve exit status from php script inside of shell script
The $output parameter of the exec command can be used to get the output of another PHP program: callee.php <?php echo "my return string "; echo "another return value "; exit(20); caller.php <?php exec("php callee.php", $output, $return_var); print_r(array($output, $return_var)); Running caller.php will output the following: Array ( [0] => Array ( [0] => my return string [1] => another return value ) [1] => 20 ) Note the exit status must be number in the range of 0-254. See exit for more info on return status codes.

Categories : PHP

Shell Script. Finish mysql dump before continuing script
In general, programs under *nix wait until completion before returning (though there are exceptions to this, mostly GUI applications). mysqldump follows this, therefore you do not have to do anything.

Categories : Mysql

Automator replacing character with apple script or shell script
Try: set myString to "This\is\my\string" -- really Thisismystring set {TID, text item delimiters} to {text item delimiters, "\"} set myString to text items of myString set text item delimiters to "/" set myString to myString as text set text item delimiters to TID return myString or set input to "This\is\my\string" -- really Thisismystring set output to do shell script "echo " & quoted form of input & " | sed 's/[\]/\//g'"

Categories : Shell

Why does ncat -exec work with a shell script but not with a perl script?
Does stopping the buffering (autoflush) of the standard output help? Add the following at the start of your Perl's cat: $| = 1; You may optionally precede this with select STDOUT; if your code did anything funky before that, but for your 3 line test script it's not needed.

Categories : Perl

Triggering a windows batch script from unix shell script
Take a look at this: http://stackoverflow.com/a/16720186/2471910 It talks specifically about invoking a windows program from another windows machine (instead of a unix machine) but the concepts are the same since ssh is available on unix as well.

Categories : Unix

email send works via perl script but not shell script
You have to export the smtp variable, otherwise mailx will not see it. Like this: #!/bin/sh SUBJECT="some subject" export smtp=10.233.1.199 EMAIL=abc@xyz.com echo "some message" | mailx -s "$SUBJECT" "$EMAIL" Btw the smtp variable is not mentioned in man mailx in my system nor in another Linux system I have access to. But I found it mentioned in an answer on superuser.com. That is to say, I'm not sure this would work on systems where it is not mentioned in man mailx, but if it works for you that's great.

Categories : Perl

Script doesn't want to run from python shell
Use execfile: >>>execfile('clean_index.py') or just run it directly (not within the python shell): $ python clean_index.py assuming you have python in your path. Or, use an import in the python shell: >>>import fibo >>>fibo.fib(1000) 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 Module import sample taken from the docs. The filename is fibo.py. Since you probably simply want to run the file, I suggest you use the second option.

Categories : Python

Python script to run shell command
Why are you using subprocess? A common practice to run Scrapy from a script is to use twisted's reactor. Taken from docs: from twisted.internet import reactor from scrapy.crawler import Crawler from scrapy.settings import Settings from scrapy import log from testspiders.spiders.followall import FollowAllSpider spider = FollowAllSpider(domain='scrapinghub.com') crawler = Crawler(Settings()) crawler.configure() crawler.crawl(spider) crawler.start() log.start() reactor.run() # the script will block here There is plenty of examples out there: Running scrapy from script (beginner) How to run Scrapy from within a Python script Running Scrapy from a script - Hangs Scrapy crawl from script always blocks script execution after scraping Hope that helps.

Categories : Python

The script which runs python in shell
It's not a python script you can simply get and modify as any .py file. In order to play around with interactive interpretter you will have to download the python sources and go through them, as it's a build-in part of it (for performance sake). You can read up the details on http://docs.python.org/devguide/

Categories : Python

use python script in shell (like fabric)
You can make your script start with the line: #!/usr/bin/env python Or, depending on your version: #!/usr/bin/env python3.3 Then you must make your script executable with a chmod, and it should work like you want!

Categories : Python

Why does this work in the Python IDLE shell but not when I run it as a Python script from the command prompt?
As @Sukrit Kalra says, don't use datetime.py as your file name. Python is getting confused with which datetime is which (and is importing itself!). Maybe; $ mv datetime.py my_datetime.py

Categories : Python

use gimp color-to-alpha script in a shell script
Ok, I have found the awnser to my post. What I was doing was pretty much wrong all the way :p So here is a batch command line that removes black baground from an image like the color-to-alpha function of GIMP : /Applications/GIMP.app/Contents/MacOS/gimp -i -b "(let* ( ( image (car (file-png-load 1 "/Users/Name/Desktop/img.png" "/Users/Name/Desktop/img.png") ) ) (drawable (car (gimp-image-active-drawable image) ) ) ) (plug-in-colortoalpha 1 image drawable '(0 0 0) ) (gimp-file-save RUN-NONINTERACTIVE image drawable "/Users/Name/Desktop/img2.png" "/Users/Name/Desktop/img2.png") ) " -b "(gimp-quit 0)" It is quite incomprehensive like this because it needs to be an inline command but it works fine on my MAC

Categories : Osx

How to run a python script from IDLE interactive shell?
The IDLE shell window is not the same as a terminal shell (e.g. running sh or bash). Rather, it is just like being in the Python interactive interpreter (python -i). The easiest way to run a script in IDLE is to use the Open command from the File menu (this may vary a bit depending on which platform you are running) to load your script file into an IDLE editor window and then use the Run -> Run Module command (shortcut F5).

Categories : Python

shell start / stop for python script
It is because ps aux |grep SOMETHING also finds the grep SOMETHING process, because SOMETHING matches. After the execution the grep is finished, so it cannot find it. Add a line: ps aux | grep -v grep | grep YOURSCRIPT Where -v means exclude. More in man grep.

Categories : Python

Capture value from shell script and use it in Python without using subprocess
Try commands module for py2.3.4, note that this module has been deprecated since py2.6: Use commands.getoutput: import commands answer = commands.getoutput('./a.sh')

Categories : Python

submit each line to a python script using shell.
This is a shell scripting question more than it is a python one. However, I think your issue is " > test.txt" the ">" will start from a blank file each time instead of appending the results. try " >> test.txt"

Categories : Python

Execute Shell Script from python with variable
Like this ? subprocess.call(['test.sh', str(domid)]) Documentation is available on the python website

Categories : Python

Shell Script inside perl script
Is this what you are looking for? $exec_string = <<EXEC; echo this is my shell script ls > tmp1 ls > tmp2 EXEC system($exec_string) EXEC can be substituted by any word (e.g. SHELL, SCRIPT, whatever).

Categories : Perl

shell script to groovy script using gant
Well at last, I have figured it out how to perform the above said task. Thanx to Grails documentation and Apache Ant tasks manual . . After taking a whole day time, I observed that for any task to be performed: one can refer to Apache Ant manual first, Find it in the index, and then knowing its usage along with necessary arguments and examples given in XML, Then observe how XML syntax is converted to corresponding Groovy script i.e., GANT script For e.g., observe the mkdir task and its corresponding usage in grails doc example i.e., use ant variable, then . task-name [ arguments-map ] For those shell commands which don't have a direct task in Apache Ant manual, use exec() to run the command That's it ... task complete :)

Categories : Shell



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.