Python Asterisk AGI imported script won't run? - python-2.7

I recently started a project where I've ro use asterisk and AGI. So I started to learn how AGI works in python by using an example found on the internet. But when I paste the example and try to run the module in Python, shell gives me in red font "ARGS: ['usr/bla bla]" ( You can see the clear output in attached image). I don't know why this happens and program won't stop running (When I try to close the shell, it says program still runs).
Note: I'm using Python in my Raspberry Pi. Pyst package has been installed there.
In above image, left side is the script that I tried to run. Or I can say the example I got from the internet. Rightside it shows the shell. You can see the program still runs.
Please help me. How can I run this properly?

Sure it not give any output.
It wait for INPUT.
Please re-read documentation about AGI, give script needed info to STDIN if for some weird reason you run it not from asterisk.

Related

how I can figure out where the output of my software is printed?

I just installed Sympol in my Ubuntu. Sympol is an open source software in the mathematics. My problem is that when I run sympol on some input data, I don't know where the output is printed. here in page 6 of this pdf (http://www.math.uni-rostock.de/~rehn/software/sympol-manual-0.1.pdf), it says the output is in .ine or .ext format but I don't know where is these output files!!!!!! please help me if you understand how it works. and it is the website of sympol for installation. http://www.math.uni-rostock.de/~rehn/software/sympol.html
I should add that when it says: Segmentation fault
Ubuntu: Assuming your app is actually running properly and you have root permissions, open another terminal, install and run fatrace, and watch for file output. When running, fatrace prints all files touched in real-time, so you should be able to see your output file's location if it's getting output.
Reading the docs again and again is almost always the correct answer, but if in this case the documentation is that bad, then watching for the file getting written is another good way to figure it out.
Windows: Sysinternals procmon (you can get it from Microsoft) can achieve the same result.

Why isn't gdb working for me

Background
I am currently trying to build an autonomous drone using ROS on my Rapsberry Pi which is running an Ubuntu MATE 16.04 LTS. Solving the Computer Vision problem of recognising red circles as of now.
Specific Problem
I am constantly getting the error I get in this question. To help me solve this, I have decided to use gdb. However, the command rosrun --prefix 'gdb run --args' zlab_drone vdstab does not seem to be working for me. zlab_drone is the name of the package and vdstab is the name of the executable I am trying to run. Since this is inside a ROS environment, I have grabbed the syntax from here, and used the suggestions in this question.
When I invoke this command, even with tui, I get a SIGSEGV and when I invoke list inside gdb itself, the program does not stay at a particular point and keeps listing a different line till it is out of range. This is quite a weird issue.
I managed to make it work without this issue earlier by using a different command, I reckon. I just cannot remember how I made it work last time.
Well, in the link you mentioned, it states clear that you should use either :
launch-prefix="xterm -e gdb --args" : run your node in a gdb in a separate xterm window, manually type run to start it
or :
launch-prefix="gdb -ex run --args" : run your node in gdb in the same xterm as your launch without having to type run to start it
So, it really looks like you missed an -ex as #ks1322 suggeseted in the comments or just type run to start the debug process.
I found out about this exclusive bug that relates to Raspberry Pi's solely. Basically the solution involves, as quoted by Peter Bennet:
There is a workaround. Start the program, then from another command
prompt or from an ssh remote login, use gdp -p xxxxx where xxxxx is
the process number. This works without crashing. If you need to debug
something that happens before you can get in from another command
prompt, add to the program a command that stops process at the
beginning of main, for example a call to gets, which will wait for you
to press enter before continuing.

Python subprocess is unstable on Windows 10?

p = subprocess.Popen([executable_file])
This is only code that I am using to run the python subprocess. However, it has unknown issue that cause my program cannot open the executable file as expected.
executable_file is one file link (PATH) that locate executable program.
Ex. C:\Users\SharkIng\Dev\WhatEverSystem\Builds\Windows\program-123456789-123456789.exe
The python subprocess.Popen should run the program. However, sometime it works and sometime it is not (I did not change any code between this two situation)
OS: Windows 10
Python: 2.7.*
Error: [Error 2] The system cannot find the file specified
BUT: It is working if you manually run subprocess.Popen([executable_file_path_string]) (with same file and path) it work.
WHY this happen?? Is that because some problem with Windows Python? or it is because my setting mess me up?
UPDATE: It is not some reason such as NOT FULL PATH. I can have it working with exact same code. If I ran same code in a python shell, by typing each line of code. It works. But if I put exact same code in a .py file and run it with python file.py, it showing the error
UPDATE 2: Another team member have same error with Windows 7 and Python 2.7.* This code used to work this morning. AGAIN I didn't change anything. That is way I am asking if it is unstable.
There is no problem with subprocess. If you want to run a specified executable, you need to give the full path to that file. The most likely reason you're seeing variable behavior is that sometimes you're in the directory with the .exe, and other times you're not.

Run a executable by python at background and still running

I have a executable made by py2exe which verifies whether my VPN is connected or not at infinite loop running on Windows. I want to make sure it runs in background or hidden, I searched for several forums and I found 2 scripts worked partially.
Rename script to scrypt.py and run py2exe again, the .exe hide when I run it, but close or vanish. Doesn't continue running after the click.
I am made another exe to call the first
import os
import subprocess
os.chdir("C:\Users\dl\Documents\Log\Py")
proc = subprocess.Popen('ipLog.exe', creationflags=subprocess.SW_HIDE, shell=True)
proc.wait()
or
os.chdir("C:\Users\dl\Documents\Log\Py")
proc = subprocess.Popen('ipLog.exe', creationflags=subprocess.SW_HIDE, shell=True)
Works but the first command still visible, and when i close it, the first exe call by it quit too.
I tried install a module call self.hide but i cant.
I am newbie in python and try to change my hobbies vb, vba to python.
Thanks for any help.
I found a solution in this thread How to start daemon process from python on windows?. Thank you all people helped with this thread, help my script too.

Imunnity Debugger PyCommands: failed to locate main function

relatively simple question here. I recently installed immunity debugger for the PyCommands feature, however whenever I try to write my own pycommand and execute it in immunity, it gives me the error message "failed to locate main function". Odd, considering I did write a main(args) function. The code I tried to use was as follows:
#!usr/bin/env python
from immlib import *
def main(args):
imm = Debugger()
return "[*] Command successfully executed."
I cannot see what is wrong with this, as I have only been following the example scripts included with Immunity. I have also checked !list which shows my command on a list of available commands, but when I try to run it from there, it still throws the error. Does anyone know why this might be?
OS: Windows XP SP3 x86 (VMWare)
Python 2.7.3
So I just figured out my own problem. The name of the command was 'test'. I'm guessing test was a reserved word or something, because I renamed it to mycommand and got the desired output. If anyone else comes across this issue with immunity, I hope this helps.