I'm currently working on a linux shell app (batch tool) using php+ncurses. I'm trying to create a loadingbar thingy but I can't get the function "ncurses_getyx" working. It doesn't return anything. I've tried using the arguments as pointers and tried as returning values, but none seem to work.
Does anyone know how I can retreive the current cursor position in the terminal window?
I'm using PuTTY on Windows 7 to connect to my server.
Thanks in advance.
I think you put the variables you want to equal the y and x values as arguments in the function, and it modifies them to equal the correct values.
Related
I have a node script that fetches all the peers. Can I filter that output using php?
I mean I dont need all the peers fetched by that script, so can i just get some specific peers using functions like strcmp? Currently my node script outputs the result in an html page. But I want it to be printed on php page with filter applied to it.
You can check lines of output one-by-one and use strpos or regexp searching functions(pref_match etc)
You also can list only some peers using construction
sip show peers like something
Technically speaking, you can do that. I would assume that your script is using the Asterisk "-rx" parameter to achieve this. Personally, that is a none reliable solution, I've seen situations in the past where running a command while "-rx", while within a script will yield no result.
My suggestion to you is to use something like PHPAGI and connect directly to the Asterisk Manager (AMI) and obtain the information from there. The solution will include less moving parts and will most surely be more reliable.
I'm trying to use WebIOPi but I'm quite lost in getting it to work with my project.
Background:
I'm using Raspberry Pi B+ running Wheezy. I'm working on a web-based application that will only be accessed locally. I have a bunch of php files in /var/www that run on Apache. Now I need to get my coin acceptor to with the project. The coin acceptor http://www.adafruit.com/products/787 sends single pulses (I only need one coin). I first tried the coin acceptor with a python script using interrupts and it works fine.
GPIO.setup(PIN_COIN_INTERRUPT,GPIO.IN)
GPIO.add_event_detect(PIN_COIN_INTERRUPT,GPIO.FALLING,callback=coinEventHandler)
But now I need to be able to capture those pulses and show them on a php page, updating the amount for every coin insert. I've been studying WebIOPi for hours but I can only find info on reading a pin's status, not listening for interrupts. Can anybody point me to the right direction?
Any help would be greatly appreciated. Thank you!
So, you seem to have two problems:
1. how do I, on the server, detect a new coin event
2. how do I then push this to the client browser.
I don't know webiopi at all, so I can't say there's not a way to use that to solve both, but as an alternative:
For part 1: you have a python program which you said works; I would suggest running as a background service and just have it do something simple like writing the latest value of coinage to a file:
GPIO.setup(PIN_COIN_INTERRUPT,GPIO.IN)
GPIO.add_event_detect(PIN_COIN_INTERRUPT,GPIO.FALLING,callback=coinEventHandler)
def coinEvenHandler(*arguments):
try:
f = open("coin.txt","rt")
cnt = int(f.read())
f.close()
except: # handle file doesn't exist and file doesn't contain an int
cnt = 0
f = open("coin.txt","wt")
f.write(str(cnt))
f.close()
For part 2:
1. Create a page which returns the value of "coin.txt"
2. Use Ajax (e.g. jquery) to poll for this value from your client page.
Ok I am using drupal 7.
I need to get information out of some tables so I can read them in a iPhone app. I found out I need a php code to convert a table to json format. I need the code to go to a database "x" then to table "y". Then list entity_id and name from all the fields. This will be a read only. I don't know the first thing about php code. Can anyone point me in the right direction? Thanks
Follow the steps :-
Learns PHP :-)
learn how drupal works
Learn Drupal hooks
Drupal query.
Once you are inside drupal you dont need to coonect to drupal database, its handled by Drupal.
After this you can use hook_menu and in call back function you can return required JSON output.
Use that link in your application.
Chheers!!!
I was given an sql database that I was supposed to do some stuff on, and I want to clean it up, given that they have stuff with "special characters" as values, such as carcaças. Notice the `ç.
My Update command just simply doesn't want to work. I've checked in a million times and the weird part is on the webservice that I'm creating using that database the line seems to do nothing, but when I go on phpmyadmin it works perfectly. It has nothing to do with permissions given that its all being hosted on my computer.
So here you go the code:
function filter($stockconn){
mysqli_query($stockconn,"UPDATE produtos SET familiaprod='Carcacas' WHERE familiaprod='Carcaças'") or die(mysql_error());
mysqli_close($stockconn);
}
So far its all very simple, simple connection file (which is working correctly 100%) being pulled towards that function.
I'm not sure how to really word this. I've been getting into PHP CLI lately, and I wanted to make like a dynamic counter. For example, it starts with echoing Count: 0 and then as the count increases (or decreases) the number changes as the program advances.
I hope you can understand what I mean. If you do, any idea on if its possible, and if so, how to do it?
As I understand you question, you don't wan't to repeatedly echo "Count: N", but you want it to remain on the screen and that only the number changes.
For this you must use the PHP extension Ncurses - http://si2.php.net/ncurses
It's basically a wrapper for the Ncurses terminal control library. It's quite powerful but not so easy to learn.
One way is to create a file somewhere in a directory like:
/files/counter.txt
Start it with a single number 0,
then every time you want to change it, read the file in
and update it. Since the only content in the file
is a number, just increment it.