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

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

Categories : Python

Gimp: python script not showing in menu
If your scritp has any syntax-error it won't show up in the menu at all - the above code dows have a synatx error on the very first line of code from gimpfu import* (missign an space before the *) One easy way to check for syntax errors is to try to run the scritp as stad alone (it will fail when it can't find the "gimpfu" module outside GIMP, but by that time, the syntax is parsed - another way is to use a lint utility like pyflakes to check the syntax. Other, run time errors, that your script might contain should appear in a pop-up window when running it from GIMP - at that stage, you can only update your script and retry it from the menus. If you change the input or output parameters form your script, though, you have to restart GIMP . And yes, the "file location" is a problem -

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

How can I execute a shell-script in a Bash sub-shell?
You can do the same but without eval. with-env-overrides() { ( source $HOME/.env-overrides "$@" ) } Example: $ cat ~/.env-overrides export A=1000 $ export | grep ^A= $ with-env-overrides export | ^grep A= declare -x A="1000" As you can see, in the second case, you've got an environment with the A variable.

Categories : Linux

exec a php to execute shell script
Your button is not actually doing anything. The problem is that your onclick attribute should contain javascript which will run when the button is clicked, not a redirect location. Use a form with a submit button instead like this. <form action="" method="get"> <input type="submit" name="run" value="Click Me!" /> </form> I notice in your question that you are also using post data in handling the form, in which case the above will not work. You need to submit the POST data at the same time as you run the script.

Categories : PHP

Crontab Jobs didn't execute shell script
The cronjobs you schedule in your settings are not actually added to the crontab until you run python manage.py crontab add. RTD

Categories : Django

how jump from staying for output of shell execute after run in an php script?
If i understand you wish to run a background process on a Windows box.Suggest try this... <?php shell_exec('start /b C:wampinphpphp5.4.3php.exe a.php'); shell_exec('start /b C:wampinphpphp5.4.3php.exe b.php'); ?>

Categories : PHP

Execute shell script in gruntfile and assign result to variable
Although I'm still unclear on why the method above is not working, and welcome any feedback, after a bit of research, I found shelljs, which I was able to use to solve my problem. Since shelljs can exec shell commands synchronously, I don't have to work with callbacks when I really want things to block: module.exports = (grunt) -> shell = require 'shelljs' envvar = shell.exec('./bin/get_envvar.sh', {'silent':true}).output grunt.initConfig pkg: grunt.file.readJSON('package.json') env: dev: ENV_VAR: envvar simplemocha: options: timeout: 30000 reporter: 'spec' compilers: 'coffee:coffee-script' all: src: ['Tests/**/*.coffee'] grunt.registerTask 'test', ['env', 'simplemocha'] A lot cleaner, too! References:

Categories : Node Js

apktool command in shell script does not execute from Java program
Well, in my experience, I would say that Java is not very fond of being ran by means of script. I did a quick google search. Try the ProcessBuilder, it looks perfect for this situation, in my opinion. I hope this helps you! :)

Categories : Java

script-fu script not load image under gimp 2.0
The error says "unbound variable: myimage". This is telling you that you are referring to a variable/function called "myimage," but you never defined that variable, so it doesn't know what "myimage" represents. Do you know what "myimage" is supposed to represent? Did you copy that from another person's script? The function gimp-file-load returns a list containing the image that you opened. You need to use the "car" function to extract the first entry from that list, so that it can be stored in your "img" variable. So instead of (img (myimage (gimp-file-load RUN-INTERACTIVE filename filename))) it should say (img (car (gimp-file-load RUN-INTERACTIVE filename filename))) Also, I think you might want to use RUN-NONINTERACTIVE instead. Similarly, I think you will need to change

Categories : Misc

Don't want php script to execute the shell command as apache user when it is executed through browser?
Sudo normally requires an interactive shell to enter your password. That's obviously not going to happen in a PHP script. If you're sure you know what you're doing and you've got your security issues covered, try allowing the Apache user to run sudo without a password, but only for certain commands. For example, adding the following line in your sudoers file will allow Apache to run sudo without a password, only for the gzip command. nobody ALL=NOPASSWD: gzip Adjust the path and add any arguments to suit your needs. Caution: There might still be complications due to the way PHP calls shell commands. Remember that it's very risky to allow the web server to run commands as root! Another alternative: Write a shell script with the suid bit to make it run as root no matter who calls i

Categories : PHP

unable to run commands in shell script after su mqm command,but able to run in putty?Pleae let me know how to execute.?
putty is interactive command line. Try the below. bash variables can be used. #!/bin/bash su - mqm -c "echo 'DISPLAY QLOCAL (<QUEUENAME>) CURDEPTH'|runmqsc QUEUEMANAGER"

Categories : Bash

How to write and execute a shell script to create a mysql databse and a table
Update During my next session, I realized mysql wasn't recognized by terminal. I realized i'm dumb and was just always doing things wrong. Do not use alias to resolve to a binary folder. Example, do not use alias mysql="/Applications/MAMP/Library/bin/mysql" Instead export PATH=$PATH:/Applications/MAMP/Library/bin/ This will allow you to use the binaries appropriately via bash, and you'll also gain access to all mysql binaries including mysqladmin etc from the terminal as well. :) Happy scripting! Example script with appropriate environment variables: #!/bin/bash echo "" echo Reloading Database echo "" echo Using echo PROJECT_BUILD_HOME: $PROJECT_BUILD_HOME echo MYSQL: $(which mysql) echo PHP: $(which php) echo "" echo "" mysqladmin -u root -pmypass drop projectbuild mysqladmin -u

Categories : Mysql

Porting windows batch file to shell script. If possible execute the task in parallel
I have to admit, I am not sure I fully understand your scenario, but to run tasks in parallel in linux, you can put them in the backgrund using &. Example: start "Engine 1500" ant start & start "Engine 1505" ant start & To call your other script, simply execute it from your first shell script. So in total you would have: clean.sh: #!/bin/sh ant -DCorrelator clean start_parallel.sh #!/bin/sh clean.sh start "Engine 1500" ant -Dengine.port="15800" -Dfamily.one="true" -Dfamily.two="false" start & start "Engine 1505" ant -Dengine.port="15800" -Dfamily.one="false" -Dfamily.two="true" start & Make sure you make both scripts executable using chmod: chmod +x clean.sh chmod +x start_parallel.sh And Linux only looks in your path (echo $PATH) for executable scripts.

Categories : Linux

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

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

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

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

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

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

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

Can't execute python script from php
Your problem is this: When launching the php script through the console, you are launching php with the permissions of your current user. When a process is executed through opening it in the browser, it will have the permissions of the user of your web-server-process. Your group permissions will have to be 7 no matter what. Either change the python scripts permissions to 777 (read-write-execute for everybody) or change it to 770 and make sure that your web-servers user is inside the group set to the file.

Categories : PHP

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

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

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

Execute python in a php script using shell_exec()
I think kernel not able to find the path for python where it is installed..if you can do echo $PATH..it will show all the paths where to be search a command if given add your python part there and then it may work or you can give absolute path(other than /usr/bin/) see if it works..I need to test it too.

Categories : PHP

Execute python script in localhost
Google App Engine SDK for Python includes a local web server application that simulates the App Engine environment. It allows for instant server script changes by just saving the file and refreshing the browser. The development tutorial is here Once you have your web site working locally, it is easy to deploy it live on Google's App Engine servers.

Categories : Python

crontab: python script being run but does not execute OS Commands
Two things: Your cd will set the directory for that subprocess, which immediately exits: subprocess.call(["cd", "/home/atweb/Documents/opengrok"]) In other words, it's a wasted step. The next subprocess doesn't know anything about the previous one's environment: subprocess.call(["./stop_website"]) ...so it won't be able to run. If you want all of your programs to run in that directory, use: os.chdir("/home/atweb/Documents/opengrok") before any of the subprocess.call() lines.

Categories : Python

Execute R script with python subprocess.call
Using commandArgs like this: args <- commandArgs(trailingOnly = TRUE) arg1 <- args[1] arg2 <- args[2] [...your code...] Also make sure that the Rscript executable is in your PATH.

Categories : Python

crontab doesn't execute my python script
First, you have an odd indentation in the line with if __name__ ==... - guess you should check it in your script. Then, make sure with what current directory your script runs, AFAIK it is your $HOME - this is where the file would appear.

Categories : Python

Execute python script using urllib2 from PHP behind Proxy
You could try passing explicit proxy settings to your Python script to see if that clears up the problem for you. I recently wrote a script that allows you to set proxy settings with command line arguments that might be useful for this case. The important parts of the script are below: # Import the required libraries from urllib import urlencode from urllib2 import Request, urlopen, URLError, ProxyHandler, build_opener, install_opener import argparse # Set up our argument parser parser = argparse.ArgumentParser(description='Does stuff through a proxy') parser.add_argument('webAddr', type=str, help='Web address of target server') parser.add_argument('--proxServ', metavar='SERV', type=str, help='Web address of proxy server, i.e. http://proxy.server.com:80') parser.add_argument('--proxType'

Categories : PHP

How to execute code when a Python script is closed out?
import MySQLdb con = MySQLdb.connect(...) cursor = con.cursor() try: # do stuff with your DB finally: con.close() The finally clause is executed on success as well as on error (exception). If you hit Ctrl-C, you get a KeyboardInterrupt exception.

Categories : Python

python run shell script that spawns detached child processes
Just some background on the methods I've tried to solve my above problem, before I go on to the answer proper: subprocess.call subprocess.Popen execve the double fork method along with one of the above (http://code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/) By the way, none of the above worked for me. Whenever I killed off the web application that executes the bash script (which in turns spawns some background processes we shall denote as Q now), the processes in Q will in a round-robin fashion, take over the port occupied by the web application, so I had to kill them one by one before I could restart my web application. After many days of living with this problem and moving on to other parts of my project, I thought of some random Stack Overflow posts and other

Categories : Python

Cannot execute Python script in Apache although permissions seem fine
SELinux is preventing you from executing the script as httpd. You need to change the file context on the CGI script to httpd_user_script_exec_t in order to execute it. See the httpd_selinux(8) and chcon(1) man pages for details.

Categories : Python

how to execute Python 3.3 script in Spyder console with variables?
You need to go Run > Configure (or hit F6) and in the dialog that it appears you need to check 'Command line options' and write (for example) there 1 2 3 After closing this dialog and hitting F5, you'll see the output you are expecting. Note: Please remember that these command line options are saved between Spyder restarts as part of the file run config, so if you want to change them, you need to hit F6 again.

Categories : Python

Use value from javascript on html page to execute python script
Here is a simple Python script that pipes the output of a locally executed command (dir on a Windows computer in this case) via a web request (using the excellent web.py library): import web from subprocess import check_output urls = ( '/', 'index' ) app = web.application(urls, globals()) class index: def GET(self): return '<pre>'+check_output('dir', shell=True)+'</pre>' if __name__ == "__main__": app.run()

Categories : Python



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