w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Running script constantly in background: daemon, lock file with crontab, or simply loop?
Using a lock file is a fine approach if using cron, although I would recommend a database if you can install and use one easily (MySQL/Postgres/whatever. NOT SQLite). This is more portable than a file on a local filesystem, among other reasons, and can be re-used. You are indeed correct. cron is not the best idea for this scenario just for the reason you described - if the process dies prematurely, it's hard to recover (you can, by checking timestamps, but not very easily). What you should use cron for is a "start_if_daemon_died" job instead. This is well covered on StackOverflow already, e.g. here: " How can I run a Perl script as a system daemon in linux? " or more posts.

Categories : Perl

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

Looping through Images When Running HTML Script
you can likely read the file in using javascript http://www.hiteshagrawal.com/javascript/javascript-parsing-xml-in-javascript and then append to an HTML element using appendChild Javascript - Append HTML to container element without innerHTML coupled with a setTimeout based on the value of your field!

Categories : HTML

HTML form opens PHP script instead of running it
Make sure that you open it localhost/yourfile.php not like C:wampyourfile.php Start all services or try xampp download tried wamp and xampp , in my opinion xampp is better

Categories : PHP

AS3 make an array of movieclip moves constantly. (this array constantly increases in size)
There may be other issues here, but: Maintaining the array length SBAlength = +1; // Sets your length to 1 Instead use: SBAlength += 1; // Increases your length by 1 But really, you might as well use the array's length property in the loop, instead of maintaining SBALength (and risking it getting out of sync due to some future code): for (var i = snowballArray.length - 1; i >= 0; i--) Manipulating arrays Also (don't think this is related to your problem, but it will certainly cause errors), in your inner loop, you're constantly doing things like this: snowmanArray[j].splice(j,1); numberArray[k].push(randomNo); // etc. That would only work if the items in numberArray and snowmanArray are themselves arrays - not sure if they are, but doesn't seem like it, since you're also

Categories : Arrays

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

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

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

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

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

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

[three.js]: script running in IE10, not running as HTA
Okay, problem understood... solution is tricky. When using Three.js code within an HTML application (HTA), then the HTA uses IE7 quicks mode by default. You can easily add the following line to the Three.js HTA: <meta http-equiv="X-UA-Compatible" content="IE=IE10" /> But then, no more HTA mark-up is understood (windowstate, applicationname - to mention just a few) since the MS IE team wants to "focus more on standards" :-( But there is a trick which works... Create an empty HTA using all the mark-up code that you like, for example: <hta:application windowstate="minimize" border="none" icon="myIcon.ico" /> Do NOT use the IE10 X-UA-Compatible meta statement here. Create an onload javascript function within that HTA that loads the THREE.js HTML page to document.location.

Categories : Internet Explorer

Append text in html tag. Javascript issue
Do the other way round, via JS (using jQuery): <script type="text/javascript"> $(".muted").html(getGenericObjName("{{n.news_type}}",{{n.news.object_id}})); </script> HTML: <span class="muted"></span>

Categories : Javascript

HTML result generated by a PHP script not recognized as HTML code
Have you closed the PHP tag ('?>') before put the HTML code? If you didn't, close them, or write echo '<form id="submit-form" action="submit-form.php" target="form-result-frame" method="post" enctype="multipart/form-data">'; echo '<iframe name="form-result-frame" id="frm-result-frame" type="text/html" width="300px" scrolling="no" height="40px" frameborder="no" src="#"></iframe>';

Categories : PHP

running pig script
I have not used node.js. But here I find a link to show how to execute a unit command in node.js: http://www.dzone.com/snippets/execute-unix-command-nodejs For example, if you want to run a pig script called foo.pig. Then you can try the following code: var sys = require('sys') var exec = require('child_process').exec; function puts(error, stdout, stderr) { sys.puts(stdout) } exec("pig -f foo.pig", puts); You can replace pig -f foo.pig to any command that you use to run your pig script.

Categories : Node Js

Don't run script if it's already running
Try using ignore_user_abort(true); it will continue to run even if the person leaves and closes the browser. you might also want to put a number instead of true false in the db record and set a maximum number of processes that can run together

Categories : PHP

Running a PHP script
What you need to do is to fork the process before you terminate it. This way when you exit the process (or close your ssh connection) the secondary process will continue to run. $pid = pcntl_fork(); if ($pid == -1) { die('could not fork'); } else if ($pid) { // parent pcntl_wait($status); } else { // child // write your code here! }

Categories : PHP

Running a script for certain days
Put this in your crontab: */20 * * * * bash /path/to/your/script.sh Then remove it after 10 days. Better yet, have your script check the current date and send you an email when it's 10 days from now to remind you to remove it. You could also just have the script remove the line from the crontab (or just remove the crontab file if it's only got this one line) after 10 days.

Categories : PHP

Running two scripts as one script
You have already identified the basic problem: The need to run the sending and the receiving concurrently. You must delve into multi-threading. The basic design pattern could be: Create a thread for the receiving part with a flag for cancelling it. Loop infinitely doing the following: check to see if there is inbound data; if there is receive it and output it; sleep a timeout; break if the cancellation flag is set. On the main thread, create your receiver and start it, then enter your input loop: If the user inputs a message, send it on the same thread. If the user types 'exit', set the cancellation flag on the receiver thread, wait for it and exit. More or less: class Receiver (Thread): def __init__ (self): super (Receiver, self).__init__ () self.cancelled = False

Categories : Python

Running a script from within a shell
the sage shell is a process running in the foreground and due to the sequential nature of your script, the sage shell has to finish running before the next line of the script is executed. It is after the sage shell exits that the easy_install line is run. The script is performing as written.

Categories : Python

Running a php script with a .bat file
The START command optionally accepts a title for the created window as its first argument; in this case, it thinks that C:Program Files (x86)PHPv5.3php.exe is the title to display and -f (the second argument) is the executable you want to run. You can therefore fix this by providing a placeholder title, e.g. start "email reminder task" "C:Program Files (x86)PHPv5.3php.exe" -f C:inetpubwwwrootsitenamecrons eminder-email.php Or, preferably, you can ditch the START command altogether (you aren't using any of its unique facilities) and just run PHP directly: "C:Program Files (x86)PHPv5.3php.exe" -f C:inetpubwwwrootsitenamecrons eminder-email.php

Categories : PHP

Keep UI updated while script is running
You can try researching WebWorkers. Or you can split your work into separate chunks and call each chunk after the next using setTimeout with a timeout of 0. setTimeout( function() { executeNextChunk(); }, 0 ) This gives the browser time to do other stuff in between invocations.

Categories : Javascript

Running exec in a script
exec will only give you the last line ... your probably want to use passthru <?php if ($_GET['run']) { # This code will run if ?run=true is set. passthru("./check_sample.sh"); } ? For passing parameters you can just form the add it to the command like this. (escapeshellarg will handle the escaping and quoting of the value for you) passthru("./check_sample.sh ".escapeshellarg($_POST["fieldname"])); If you need the output as a string your options are to use popen or surround the passthru in an output buffering block: ie: ob_start(); /* passthru call */ $data = ob_get_clean();

Categories : PHP

Why isn't my 'cycle' script running?
Also include Jquery.min.js <script type="text/javascript" src="scripts/jquery.min.js"></script> before your cycle.js Wordpress has already Jquery Loaded so you can remove your jQuery.js from your script and try ..I suppose its mere Jquery Conflict

Categories : Javascript

How do you debug a LONG RUNNING php script?
Xdebug does not have functionality for this. Using pcntl_signal and then using xdebug_print_function_stack is an option, but what you can also do is to create a "function trace". This is something that makes Xdebug write every function call to disk as soon as they happen. This should be able to tell you where your script hangs. From what I can see though is that is waiting for IO. There is more information about function traces at http://www.xdebug.org/docs/execution_trace

Categories : PHP

Check if server running script?
First find IP address of the machine requesting the link by: if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } Now $ip is IP address of the requesting machine. And let's say your computer IP is 123.456.789.1 (something like that) So let's assign it to a variable $server_ip = "123.456.789.1"; Now if($ip == $server_ip && isset($_GET['reloadImages'])){ echo "<img src="site.com/image.jpg" />"; exit; } else{ echo "Sorry! you cannot see"; }

Categories : PHP

Xdebug interrupts the running of PHP script
500 (Internal Server Error) in phpstorm 9.0 when enabling xdebug breakpoints. Validate your whatches for php session. Errors in whatches can generate errors in executing php code. Errors disapears when you disable xdebug listening or correct/remove whatches.

Categories : PHP

Check status of running php script
You want to avoid using a db because of performance, but somewhere you need a flag or other way of identifying that the script is running. PHP sessions are out since someone viewing it from another session wouldn't have the same flag set. Try using something faster than a DB - like memcache. <?php // if memcache->is_running is set // echo some response message saying it's running and exit // set memcache->is_running w/ the start time maybe // ... your code // write memcache->is_running start timestamp and end timestamp to db or file // clear memcache->is_running

Categories : PHP

Running Scrapy from a Shell Script
Perhaps you actually need to run the script in ~/.virtualenvs/email-scraper/. Do cd ~/.virtualenvs/email-scraper/ before running it. When you're there run sh sitecode/runspiders.sh Or sudo sh sitecode/runspiders.sh #!/bin/bash cd /home/pi source ./bashrc ## source /usr/local/bin/virtualenvwrapper.sh ## You didn't run this. workon email-scraper cdvirtualenv cd ./sitecode/jobscraper scrapy crawl site1 Run as bash script.sh, not sudo sh script.sh.

Categories : Bash

How to detect a running script on windows?
You can use the isAlive method on the thread to check if it is already running. On similar lines, if you were running a process instead, then you could write a pid file everytime you start the process and query the OS for the status of that specific pid anytime you required. Check the following link for more on isAlive. http://docs.python.org/2/library/threading.html#threading.Thread.isAlive

Categories : Python

JSF rendering and running order
I would just use jQuery: <tr:document> <trh:script source="jquery.js"></trh:script> <trh:script source="your_script.js"></trh:script> ... </tr:document> You can then just execute your script on page load (.ready): $(document).ready(function(){ // Your stuff here }); If you are using Ajax (Trinidad Partial Page Rendering), you might want to add a state change listener in your Javascript. For example: TrPage.getInstance().getRequestQueue().addStateChangeListener(function(state){ if (state == TrRequestQueue.STATE_READY){ // Your stuff here } });

Categories : Java

302 Found when running the Perl Script
You print your HTTP header here: print $q->header Then you print another HTTP header here: print $q->redirect($client->get_login_url()); An HTTP message can have only one set of headers. If you're sending a 302 redirect, then there's no need to print any HTML either, so get rid of all of this: print $q->header, # create the HTTP header $q->start_html('Facebook App'), # start the HTML $q->h1('Facebook Authentication'), # level 1 header $q->end_html; # end the HTML

Categories : Perl

Glitch when running homemade script CMD
where is your procedure definition and it's call ? you shoud have done someting like : echo parsing ... call :delay 3000 echo reading ... call :delay 3000 exit :delay ping 1.1.1.1 -n 1 -w %1 > nul

Categories : Batch File

Testing php code while running script
You don't want to do such a thing, because it will immensely slow down your software. Typically your software (and your tests) only changes when you deploy a new version to your production server. You could use an continues integration (CI) server which you can configure to automatically run your testsuite whenever you commit to VCS or before you deploy.

Categories : PHP

UIAutomation script not running on device
I had the same problem and then (eventually) figured it out. Turns out the build has to be a DEBUG build so that instruments can attach to it. I edited the scheme build settings for "build for profiling" so that it would build a DEBUG build rather than a RELEASE build and things started working.

Categories : IOS

Script is not running at the same time as the loop
Definitely your addGraph complete function gets called asynchronously. You can work around this like this. <script> console.log ("LOOP"); var impressions = [<?= implode(",", $prod_impression_dots) ?>]; var testdata = [ { "key" : "Impressions" , "type": "line", "values" : impressions, "yAxis": 1 } ].map(function(series) { series.values = series.values.map(function(d) { return {x: d[0], y: d[1] } }); return series; }); nv.addGraph((function (testdata) { return function() { console.log ("Add graph is called here"); console.log (testdata); var chart = nv.models.multiChart() .margin({top: 30, right: 60, bottom: 50, left: 70}) .x(function(d,i) { return i })

Categories : PHP



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