w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Re-installing Linux O.S. and then running bunch of commands in a .sh script , how to stop the script if something fails?
You can check the error code from commands you run #!/bin/bash function test { "$@" status=$? if [ $status -ne 0 ]; then echo "error with $1" exit 255 fi return $status } test ls test ps -ef test not_a_command taken from here for more information Bash Beginner Check Exit Status

Categories : Linux

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

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

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

Running pig script gives the error as: job has failed. Stop running all dependent jobs
After some research, I found that the problem here is LeaseExpiredException. This might be because the output of mapper was removed. One of the reason for this might be due to the quota allocated for the user. In my case, I was running this script in a very large data, and my quota was insufficient to process/store the data. We can check the quota by the following command: hadoop fs -count -q /user/username Thank you.

Categories : Hadoop

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 prevent "Stop running this Script" in browsers?
The problem is javascript is single-threaded, so if there is a function that takes too long to complete, this function could cause the UI not responding. Therefore, the browser will warn the user about long running script by displaying the message: "Stop running this script". The solutions to this problem are: Optimize your code so the function does not take so long. Use setTimeout to break the function execution into many pieces that are short enough. Example code pattern: var array = []; //assume that this is a very big array var divideInto = 4; var chunkSize = rowCount/divideInto; var iteration = 0; setTimeout(function doStuff(){ var base = chunkSize * iteration; var To = Math.min(base+chunkSize,array.length); while (base < To ){ //process array[base] base++;

Categories : Javascript

how to stop running any script inside html?
You can't stop the user from running script, nor can you guarantee that they will run your script. The browser, and any scripts that run there, are outside of your control. Any important security code needs to run on the server - that's where you need to validate the fields. That's the piece of the system that you control.

Categories : HTML

Running VBA script causes excel to stop responding
So, some tips for you: 1st. (according to comment) Add as a first line to your sub: Application.ScreenUpdating = false and add the other line right before End Sub : Application.ScreenUpdating = true 2nd. Move this line (it's setting constance reference): Set wb = Workbooks("Equipment Further Documentation List.xls") before: Do Until txtStream.AtEndOfStream 3rd is just a tip. To see the progress of your sub add the following line: Application.StatusBar = file.Name after this line: Workbooks.Open strNextLine & Application.PathSeparator & file.Name Before the End Sub add additionally this code: Application.StatusBar = false As a result you can see in Excel app, in the status bar, file name which is currently in process. Keep in mind that working with 500 files mus

Categories : Excel

How to stop bots from running some code on PHP script?
you could make a robots.txt file restricting bots from accessing the pages or directories that you don't want them too. Here is a link that will show you how the robots.txt works Robots.txt

Categories : PHP

How to stop a script running in a tmux session?
From https://gist.github.com/henrik/1967800: tmux kill-session -t myname You can also run a command with it's input from a named pipe (created using mkfifo). Check out http://www.catonmat.net/blog/bash-one-liners-explained-part-three/

Categories : Bash

How to stop Jquery from running more than once until the script is finished
You can use the following code inside your function: $(document).ready(function() { $('#search-container .trigger').mouseover(function(e) { $('section .search-bar input').stop(true,true).animate({width:"150px"}, 750, function(){ $(this).find('input').first().focus(); }); $('.search-bar').stop(true,true).animate({width:"185px"}, 750, function(){ $(this).find('input').first().focus(); }); }); $("#search-container .trigger").mouseleave(function(e){ $("section .search-bar input, .search-bar").stop(true,true).animate({width:"0px"}, 750, function(){ $(this).find('input').first().focus(); }); }); });

Categories : Javascript

How to stop TDDium from running script/cucumber features automatically
If you have never run the test suite for your current branch, Tddium will simply pick up the test pattern and use it. If you have already configured the suite for the current branch, the simplest solution is to run tddium suite --edit.

Categories : Ruby

Facebook like button/box causing "Stop running this script" errors in IE8
we had the same issue on website. It started to happen from yesterday 04/07/2013. It only happens in IE7 browser. We just omitted the browser from showing the Like box with below code. if (navigator.appVersion.indexOf("MSIE 7.") == -1) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }

Categories : Facebook

OSGi threads never stop running, defining fixed lifetime for threads
You must finish your threads and release every resources when the bundle is stopping. You can do it for example in the BundleActivator stop method. In case you have new threads you should also be sure that the threads finish their job before the stop function returns. This means that if your jobs need to run for a long time before finish (e.g. due to an iteration) they should be designed in a way that they can be interrupted.

Categories : Java

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

Running a .py script from bash, how can I pass a python variable back to the terminal once the .py is done running?
You can write your variable and its value into an ini file from the python script. In Values.ini file my_var="value" After executing python script, just invoke Values.ini using . operator . Values.ini Now your shell variable $my_var will be having the assigned value. The advantage with this method is that you can assign any number of variables like this. var1="value1" var2="value2" var3="value3"

Categories : Python

Running python script on crontab is causing permissions errors but running via terminal is fine
@Lucas Ou-Yang @Hyperboreus as Hyperboreus said it depends on the user privilege who run it . i think that if you give the /tmp/ dir a 777 permission from the root account it'll be fixed : chmod 777 -R /tmp/ okay try with : chmod 777 /tmp/ if the error still check if the directory /tmp/ exist !

Categories : Python

Stop script inside an other script - Adobe Javascript
If you return false from the submit handler it will cancel the submit event. You can change your DateDiff.inDays call to into: if (!DateDiff.inDays(d2, d1)) { return false; }

Categories : Javascript

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

Stop Python script from shutting down on small errors
First of all, the PHP language made many bad design decisions, this is just one of them. Be happy that python detects and handles these problems in a nice way. I personally always wrote PHP code that never created any warnings. Once you have warnings it's hard to distinguish what's acceptable and what's a real problem. Second, you can handle the problem several ways: You can handle these exceptions in an upper layer (1 or 2, instead of a dozen) You can use a defaultdict. You can use a utility function. Example: def getkey(d, k): try: return d[k] except KeyError: return "" Note that all these solution have the serious flaw that they make your code brittle. You won't detect all the possible typos you can make for the keys. I think the most clear way would be to fill your

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 to run a script that it has to connect 3 solaris servers, do some operations and create files in the machine where the script is running?
Use sshfs to mount the needed directories of your three servers. Afterwards you can run the script locally accessing the remote data as local files.

Categories : Bash

Running Fiji script in python
Python (or, to be precise, Jython) scripts within Fiji are executed using the org.python.util.PythonInterpreter class (see source code). It doesn't make much sense to run a Jython script within a Java instance that is started from with Python, but have a look at those two questions concerning how to run external commands in python. You can save your script in a file myscript.py and then do: call(["./ImageJ-linux64", "myscript.py"]) using the ImageJ launcher from the command line. The other way is to use ImageJ as a library and just import the classes you need for your script, as others have suggested: from ij import IJ

Categories : Python

python script see traceback when running as background
I use something like this. It will dump the exception which caused termination to your syslog, which you can see by examining /var/log/syslog after your script has stopped. import traceback import syslog def syslog_trace(trace): '''Log a python stack trace to syslog''' log_lines = trace.split(' ') for line in log_lines: if len(line): syslog.syslog(line) def main(): # Your actual program here if __name__ == '__main__': try: main() except: syslog_trace(traceback.format_exc())

Categories : Python

nmap script running error in python
Seems that python-nmap is meant to be run on Linux… but you can still try to make it work on Windows. The problem is that it is trying to call nmap but the binary is not found in PATH. Add the directory with nmap executable to you PATH variable. Here is a HOWTO.

Categories : Python

Confused about running Scrapy from within a Python script
Terminal prints the result because the default log level is set to DEBUG. When you are running your spider from the script and call log.start(), the default log level is set to INFO. Just replace: log.start() with log.start(loglevel=log.DEBUG) UPD: To get the result as string, you can log everything to a file and then read from it, e.g.: log.start(logfile="results.log", loglevel=log.DEBUG, crawler=crawler, logstdout=False) reactor.run() with open("results.log", "r") as f: result = f.read() print result Hope that helps.

Categories : Python

Running Python script from PHP by using an AJAX call
As a first step, I would try outputting json from python. What you are getting from python currently is a bunch of lines (a single string), not a valid json encodable list. Also, you wouldn't need the Content-Type in the data as that is a header for use in HTTP. Instead, try this: PYTHON import json ... data_out = [eyeSize, displacementX, ...] print json.dumps(data_out) PHP exec("python myscript.py",$return); echo $return;

Categories : PHP

Python ImportError when running an installed script
I just spent some time coming to grips with this problem on my own project before I realized I was not properly respecting the python import path. When the name of the script you are running matches the root of your namespace there will be namespace problems. opal.py is conflicting with opal/init.py. This can even happen when using setuptools as you are. Assuming SITEPACKAGES=/usr/lib/pythonX.Y/site-packages your package will be installed at $SITEPACKAGES/opal-$version.egg and your scripts will be installed in $SITEPACKAGES/opal-$version.egg/EGG-INFO/bin/opal.py with a file added to /usr/local/bin that loads the script that is placed in EGG-INFO/bin/. When that script loads there is a small problem. The python path will include $SITEPACKAGES/opal-$version.egg/EGG-INFO/bin/. When the

Categories : Python

Running window apps from python cgi script
I found solution. There is an option "allow service to interact with desktop" in tab "Log On" in service properties. After checking it out, and restarting Tera Term Works fine. Tera Term window does not apear. Solved!

Categories : Python

running a persistent python script from systemd?
What about usig nohup? http://en.wikipedia.org/wiki/Nohup nohup is a POSIX command to ignore the HUP (hangup) signal. The HUP (hangup) signal is by convention the way a terminal warns dependent processes of logout.

Categories : Python

jQuery mobile stop running the script in the current page used after moving to the next page
As, Omar suggested I want to give an id instead of $(document). Using pagebeforeshow or pageshow , pagehide and Clearing the interval will solve this issue. The following code works for me, var auto_refresh; $("#light-page").on('pagebeforeshow', function(){ auto_refresh = setInterval(function () { // code }, 3000); }); $('#light-page').on('pagehide', function () { clearInterval(auto_refresh); }); Adding id in Html: <div data-role="page" id="light-page"> </div>

Categories : Javascript

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

Running a variable script with parameters through a script
If you do this: #!/bin/sh for app in "$@"; do sh "jboss-$app" restart done Then you can pass a space-separated list of app names to the script ./restart-apps app1 app2 app3 ...

Categories : Shell

Running Python script causes Raspberry Pi to lose power
I tried your script. It locks up the rpi at this line GPIO.setup(6,GPIO.IN,pull_up_down=GPIO.PUD_DOWN) GPIO06 isn't one of the pins on the GPIO port. You'd have look at the schematic to see what it's connected to. Looks like it's LAN_RUN. What are you trying to do with it? From elinux.org GPIO06 is LAN_RUN and is available on pad 12 of the footprint for IC3 on the Model A. On Model B, it is in use for the Ethernet function. So unless you have a model A, you shouldn't be using GPIO06

Categories : Python

Is there a way to automatically verify all imports in a Python script without running it?
No, this is not possible, because dependencies can be injected at runtime. Consider: def foo(break_things): if not break_things: globals()['bar'] = lambda: None long_result = ... foo(long_result > 0) bar() Which depending on the runtime value of long_result, may give NameError: name 'bar' is not defined.

Categories : Python

running an ironpython script from python : sandbox, loadFromRemoteSources
OK I just figured it out. It actually works, the thing is you need to add a config file called ipy.exe.config containing the following : <configuration> <runtime> <loadFromRemoteSources enabled="true"/> </runtime> </configuration> see here -> How do I setup configuration when I use command line to build C#/.NET?

Categories : Python

Python Script not running in crontab calling pysaunter
What you've said makes no sense. You say shell_env = sys.path. sys.path is a list of folders for python to look for modules, not an environment variable mapping! You then use that in subprocess.call. Perhaps you meant to write env=my_env. That's the next problem. First, PATH should be a list of folder separated by ':'. You just tack shell_path onto the last folder. Finally, python uses PYTHONPATH as a list to locate python modules (which seems to be what problem you're having.)

Categories : Python

Detect from a running python script if the optimize flag is -O or -OO
After some digging in the documentation I've found that the sys.flags struct sequence (http://docs.python.org/dev/library/sys#sys.flags) that has an optimize attribute containing the information I was searching for. python -c "import sys; print sys.flags.optimize" -> 0 python -O -c "import sys; print sys.flags.optimize" -> 1 python -OO -c "import sys; print sys.flags.optimize" -> 2

Categories : Python

Running a python QIIME script on multiple files
I do not know what about 'split_libraries.py' It seems that this script writes the error message. Cope this "line 4" and invoke it directly in your terminal. What happens? Where did you get the '...txt' file? Is one of the input files in wrong format or wrong encoding?

Categories : Python



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