w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Raspberry PI: PHP call python script with sudo
Mm, i have try with this two simple example: /Scripts/test.py #!/usr/bin/env python print (str('hello world')) /var/www/test.php <?php echo shell_exec('/Scripts/test.py'); ?> via a browser, show me "hello world" Perhaps try this: chmod a+x your_py_file.py Hope that help..

Categories : Nginx

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

Twisted Python script on Raspberry Pi (Debian) to communicate with Arduino via USB
Judging from this: http://twistedmatrix.com/trac/browser/tags/releases/twisted-12.3.0/twisted/internet/_win32serialport.py#L84 you should be looking at dataReceived(self,...) method of your Protocol subclass Thus: class USBclient(Protocol): def connectionMade(self): global serServ serServ = self print 'Arduino device: ', serServ, ' is connected.' def cmdReceived(self, cmd): serServ.transport.write(cmd) print cmd, ' - sent to Arduino.' pass def dataReceived(self,data): print 'USBclient.dataReceived called with:' print str(data) try this to see if it works.

Categories : Python

Play videos automatically in Raspberry Pi Qt
If you want to use omxplayer, then you should checkout it here: https://github.com/popcornmix/omxplayer. I see from the code it can be controlled using a pipe. EDIT: omxplayer also has a dbus interface.

Categories : Linux

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

executing a script after the user has logged in, on Raspberry pi
Raspberry PI runs a Debian OS. A related discussion on how to run python scripts at startup can be found here If you want to run the script whenever a new terminal is launched, you need to update your .bash_profile, .profile, .bashrc files. More on this here

Categories : Misc

How can I run a PHP script in a .css file and it will be fully working?
<?php header("Content-type: text/css"); // and echo your CSS code... But don't do it, it's not worth it. Just save the dynamic CSS to a CSS file every time it changes

Categories : PHP

wait for angular app to be fully rendered from phantom script
The associated PhantomJS API is onCallback; you can find the API doc on the wiki. // in angular $scope.$on('$viewContentLoaded', function () { window.callPhantom(); }); // in the phantomjs script var page = require('webpage').create(); page.onCallback = function() { page.render('snapshot.png'); phantom.exit(); }; page.open('http://localhost:9000/'); You can get access to the $rootScope by accessing the injector; for example, if you're using the ng-app directive, you can find the element with the directive and call .injector().get("$rootScope") on it. However, I'm not sure if the $viewContentLoaded event will already have fired by then.

Categories : Angularjs

NFC tag reading in python on raspberry pi
There are lots of links on google wherein you can find information on data format used in NFC. Some of them are http://learn.adafruit.com/adafruit-pn532-rfid-nfc/ndef http://developer.nokia.com/Community/Wiki/Understanding_NFC_Data_Exchange_Format_(NDEF)_messages

Categories : Python

JavaScript waiting until an image is fully loaded before continuing script
Maybe this will help: currentimage.onload = function(e){ // code, run after image load } If it is necessary to wait for the image to load, the following code will load the next image (currentIndex is your "img" variable): var loadImages = function(imageURLarray, currentIndex){ if (imageURLarray.length == 0 || imageURLarray.length == currentIndex) return false; if (typeof currentIndex == 'undefined'){ currentIndex = 0; } // your top code currentimage.onload = function(e){ // code, run after image load loadImages(imageURLArray, currentIndex++); } } Instead of a "for" loop, use for example this function: loadImages(imageURLarray);

Categories : Javascript

How to fully collapse and alter content of a website without client script?
It's called "responsive web design". Using CSS you can detect the size of the active window and adapt the format of your content accordingly. By doing this, you ensure a consistent experience to all your users no matter the device (and its screen size) there are using. It's not done with any server side technology, neither with Javascript but only with CSS. Here is a good presentation if you want to know more about this: http://johnpolacek.github.io/scrolldeck.js/decks/responsive/ And a lot more if you google it.

Categories : Javascript

How to pass boots args to a Hyper-V VM
AFAIK the only way to do this with Hyper-V is to mount the vhd and edit the file. or, use a virtual floppy (which I don't think will have any effect in your case). This can be done through wmi. Hyper-V does not have an equivalent to the PV vm of xenserver. Where many of these xenserver pv arguments are simple configuration of a boot file in the settings of the vm, as the vm gets boot strapped from the parent kernel. if you could do this with a xenserver HVM style Linux vm, then there might be a similar equivalent in Hyper-V.

Categories : Misc

Raspberry Pi Python PWM RuntimeError: No access to /dev/mem
The problem is with the code above is that I forgot to set RED to at output before trying to use it. The error message did not help resolve this problem. Next time, I need to remember to setup PWM pins as outputs before trying to use them.

Categories : Python

Running program from pendrive before windows boots
Is the program an executable file? Did you try looking into Windows registry? The following key is where the virus/malware usually attached itself during windows logon. A warning though, any mistake will cause you unable to go into Windows, you have to remotely modify the registry using Bootdisk. HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon

Categories : Windows

Using Python smbus on a Raspberry Pi - confused with syntax
I'm absolutly not sure this is the problem, but according to the specs p22: MMA7660FC is read using it’s internally stored register address as address pointer, the same way the stored register address is used as address pointer for a write. The pointer generally auto-increments after each data byte is read using the same rules as for a write (Table 5). Thus, a read is initiated by first configuring the device’s register address by performing a write (Figure 11) followed by a repeated start. The master can now read 'n' consecutive bytes from it, with the first data byte being read from the register addressed by the initialized register address. As far as I understand, to "read" from a register, you have to start by writing the register address, and then blindly read a byte

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

No video file created by OpenCV 2.3.1 with Python on Raspberry Pi
I eventually went through and tried all of the fourcc codecs and none worked. Same with the mpeg2 codec. I ended up using avconv to create and capture the video with this line: import os os.system("avconv -f video4linux2 -input_format mjpeg -i /dev/video0 output.avi") os.system() is used to run a terminal command. OpenCV can still be used to process the video files at a later time. Hope this helps someone.

Categories : Opencv

Raspberry pi will not send serial data to an arduino using either minicom or python
You need to read up on the difference between arduino and raspPI 'serial' pins - in short, their voltage levels are quite different and require a conversion cable between the two of them to adjust these levels.

Categories : Python

How can I make a connection between Raspberry Pi and a Bluegiga WT11i Bluetooth Module using Python?
Got it!! pi@raspberrypi ~ $ aptitude install bluetooth pi@raspberrypi ~ $ hcitool dev Devices: hci0 00:07:80:54:CA:E2 pi@raspberrypi ~ $ hcitool scan Scanning ... 00:07:80:54:CA:E2 BGWT11i pi@raspberrypi ~ $ bluez-simple-agent hci0 00:07:80:54:CA:E2 Enter PIN Code: 1234 Now I can connect ... pi@raspberrypi ~ $ python rfcomm-client.py 00:07:80:54:CA:E2

Categories : Python

Python having trouble accessing usb microphone using Gstreamer to perform speech recognition with Pocketsphinx on a Raspberry Pi
So I finally got this guy working. Couple key things I needed to realize: 1. Even if you're using Pulseaudio on your Raspberry Pi, as long as Alsa is still installed you're still able to use it. ( This might seem like a no brainer to others, but I honestly didn't realize I could still use both of these at the same time ) Hint via (syb0rg). 2. When it comes to sending large amounts of raw audio data ( .wav format in my case ) to Pocketsphinx via Gstreamer, (queues) are your friend. After messing around with gst-launch-0.10 on the command line for a while I came across something that actually worked: gst-launch-0.10 alsasrc device=hw:1 ! queue ! audioconvert ! audioresample ! queue ! vader name=vader auto-threshold=true ! pocketsphinx lm=/home/pi/dev/scarlettPi/config/speech/lm/scarlett

Categories : Python

Porting Python Raspberry Pi application to Twisted - how to handle background threads that poll the hardware
You can use LoopingCall (howto) to schedule a repeated function call on a certain interval. This probably replaces your polling threads entirely.

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

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

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

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

Run a ruby script automatically after modification
Perhaps something like Guard may help. Railscast Gem

Categories : Ruby

Running script automatically in vagrant
You can use inline script in Vagrantfile, even Here Document which made complex shell scripts embedded in it possible. Example: $script = <<'EOF' echo shell provisioning... date -R > /etc/vagrant_provisioned_at EOF Vagrant.configure("2") do |config| config.vm.provision :shell, :inline => $script end NOTE: single quoted LimitString is to escape special characters like or$`. Check the Docs out => http://docs.vagrantup.com/v2/provisioning/shell.html

Categories : Misc

Automatically load map in R from script on startup error
The problem you are getting is that .First scripts can only use functions in the base package, unless the packages have been explicitly loaded. So in your case, you need to load utils for the data function. graphics for the par function. Putting this together gives: .First <- function() { library(utils); library(graphics) library(maps) library(maptools) library(mapdata) map('worldHires', c('UK', 'Ireland', 'Isle of Man','Isle of Wight'), xlim=c(-11,3), ylim=c(49,60.9)) }

Categories : R

background shell script terminating automatically
Ok, after hours and hours i finally found a solution, it might (must) be a bit dirty but it works ! As i said in a previous command, i used the trap command, here is my final script : #!/bin/sh #get the script directory SCRIPT=$(readlink -f "$0") script_path=$(dirname "$SCRIPT") #trap SIGHUP SIGINT SIGTERM and relaunch the script trap "pkill -9 inotifywait;($SCRIPT &);exit" 1 2 15 for f in `ls "$script_path"/data/` do php myscript.php "$script_path"/data/$f & done #watch the directory for file creation inotifywait -q -m --format %w%f -e create "$script_path"/data/ | while read -r line; do php myscript.php "$line" & done hope it will help shell beginner as me :) Edit : added "pkill -9 inotifywait" to make sure inotify process won't stack up,the parenthesis to mak

Categories : Bash

how to run php script automatically every minute without access to that page?
If you are wanting to send a confirmation email to the user once they have registered, you can use php mail function to do this. http://php.net/manual/en/function.mail.php

Categories : PHP

How to answer questions automatically using shell script
Try writing a expect script, which could be used to automate your iteraction with the shell. Reference this: http://linux.die.net/man/1/expect, or just the man page.

Categories : Unix

How can I run a google script automatically on multiple sheets in the same spreadsheet
There is no active sheet when your function runs as a trigger. The active sheet is applicable only when a user has the spreadsheet open. Modify your script to use getSheetByName and everything should work fine. If you want this to work on multiple sheets, just call this function from another function.. function shellFunction(){ var sheets = ['sheet1','sheet2',etc]; for (var s in sheets){ toTrigger(sheets[s]); } } And change your toTrigger function to receive the sheet name as argument. function toTrigger(sheetName){ var sh = SpreadsheetApp.openById(ID OF SPREADSHEET).getSheetByName(sheetName); /* Your regular code */ }

Categories : Google Apps Script

How can i trigger this jquery script to automatically run after a set amount of time (5 seconds maybe)?
Assuming you want the click handler to only bind after 5 seconds: $(document).ready(function(e) { var $dropdownwrap = $('.dropdownwrap'); setTimeout(function() { $('#dropdown').on('click',function(){ $dropdownwrap.slideToggle(); }); }, 5000); }); The main thing to take away is the setTimeout method which allows you to execute a function after a certain period of time, in this case 5000ms. More information on the setTimeout function on MDN.

Categories : Jquery

How to call a bash script automatically when directory contents chage
Linux provides a nice mechanism for that purpose which is called inotify. inotify is mostly available as a C API. But there have been developed shell utilities as well. You should use inotifywait from inotifytools (pkg name in debian) for this. Here comes a basic example: #!/bin/bash directory="/tmp" # or whatever you are interested in inotifywait -m -e create "$directory" | while read folder eventlist eventfile do echo "the following events happened in folder $folder:" echo "$eventlist $eventfile" done Update: If the problem goes complicated, for example you'll have to monitor recursive, dynamic directory structures, you should have a look at incron It's a cron like daemon which executes scripts on certain events. But the events are file system events rather than timer eve

Categories : Linux

Chef-solo and vagrant to automatically run an MySql script after install?
For this, I would recommend using Chef since you are already in the Chef/Vagrant env. No need to create a shell script and trigger it from within Chef - it would go against the intended flow of Chef/Vagrant. You can do something along the lines of (taken and simplified from the MySQL cookbook by OpsCode in the server.rb recipe): execute "mysql-install-privileges" do command "mysql -u root -p#{node['mysql']['server_root_password']} < /vagrant/command.sql" end You can determine on your own how you want to store the mysql path, username and password. The general idea is that you define your MySQL commands in a .sql file (saved in your templates or file directory within your cookbook) and then run it with plain MySQL commands. Hope that gets you on the right path.

Categories : Mysql

Extract .tar File to Current Directory Automatically with Shell Script
You can try: -C, --directory DIR change to directory DIR and $(dirname "$x") for file directory for x in in /home/davidwright/attachments/*/*.tar do echo "extracting $x" tar -xvf "$x" -C "$(dirname "$x")" done

Categories : Bash

Is there a way for maven script to automatically download dependent jars of dependencies i specify in a pom
Yes you can download from MAVEN Central repository by specifying central repository location in your maven home. ie .m2/settings.xml <mirror> <id>mirrors.dotsrc.org</id> <name>Mirror of http://repo1.maven.org/maven2/</name> <url>http://repo1.maven.org/maven2/</url> <mirrorOf>central2</mirrorOf> </mirror> and in your pom add following.. <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.2.3.RELEASE</version> Please refer. http://search.maven.org/#search|ga|1|g%3A%22org.springframework%22

Categories : Maven

Ant task imported from build.xml in Gradle script is running automatically
Seems to work as expected. The build script makes jar depend on antCompile, which according to your words depends on -compile. assemble depends on jar, so executing gradle assembmle should run -compile first. In any case, it should be said that ant.importBuild has known limitations, and can result in differences in behavior compared to running the Ant build directly. Also you'll lose many of Gradle's advantages when not describing the build in terms of Gradle's own abstractions. Therefore I recommend to port the build to Gradle, rather than using ant.importBuild (which isn't used that often in the real world). Note that it's perfectly fine to reuse Ant tasks in cases where Gradle doesn't provide any equivalent.

Categories : Ant

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

script for accessing remote server, get error log and rename it automatically.
The easiest way to accomplish this would be to setup an automated job on Gorilla4. Your first problem, is that you'll need to setup password-less SSH access between Gorilla4 and Monkey so you don't need a person to physically type in the password. While you can do this with the 'root' user I would STRONGLY recommend against it. Instead create a maintenance user on BOTH hosts: $ useradd -m maintuser Then switch to the new user and create SSH key on Gorilla4: $ ssh-keygen -t rsa -b 2048 Accept the defaults when prompted. Then copy the id_rsa.pub file to the ~/.ssh directory of the maintuser on Monkey. Now, when you are the "maintuser" on Gorilla4, you can SSH to Monkey without a password. Then you can create a script called "copy_log.sh": #!/bin/bash # copy_log.sh log_path="/pa

Categories : Shell



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