My question is stated in the title: How can I discover whether my program is being execute manually or by cron or from another script, and what account is being used? I hope you guys can help me. Answer You can get the parent PID with getppid. Then finding the parent process name from its PID is non-portable.…
How do I handle POST requests in Twisted?
I’m trying to write a script where someone can type the name of a website into a box and my script will render the resources of that website. I’m not sure how to go about it, I’m thinking it would like something like this: This script just isn’t working, when the script I get an Error:…
Replacing strings with special characters in command line sed
I want to uncomment a line of a config file by replacing the line %% {some_string, []}, with {some_string, []} in the command line. I have tried a few different formats using sed: sed ‘s/%% {some_string, []},/{some_string, []}/’ filename sed “s/%% {some_string, []},/{some_string, []}/”…
Prevent case statement from continually asking for input so that I can carry out subsequent commands
I have the following code which includes a case statement. My problem is that once a file is selected from the option menu, it subsequently keeps asking me to input further choices, but I only want to input one then carry out out the subsequent commands (in this case the subsequent command is at the bottom (e…
Sending a command to screen in linux
In order to run a data analysis program, installed on a Teensy 2.0 microcontroller running arduino, I have to go to the screen by typing screen -S trans -L /dev/ttyACM0 (the name of the screen is trans). Once in the new screen, I have to enter ‘s’ to start the scanning process. I am trying to writ…
unterminated `s’ command error – trying to remove extra double quote
I am trying to edit a single row in a text file, by removing an unnecessary double quote in front of the name, i.e. “THE DELEON FAMILY DE. After the change it should look like this: THE DELEON FAMILY DE. Here is my code: This is the error I get: Answer You are missing a the last / in the
Reading 2 byte at a time from a binary file
I have an elf file that called example. I wrote following code which it’s read the content of the example file in the binary mode and then I wanted to save their content in another file called example.binary. But when I run the following program it shows me a segmentation fault. What’s wrong with …
How to check a email in linux server automatically?
I have a Ubuntu 14 server, I have to assign a email account to this server, when some person write a email to this account, the server have to open this mail automatically, and check if there are a specific information, if yes some thing happen. I suppose that the email are stored in a data base o something l…
How to connect to my remote SQL server
I have a linux ubuntu server that I rent from DigitalOcean for storing streaming real time data in MySQL by coding with python. Problem is that I am coding not in the linux server environment but in my local computer python(personal Windows 10(not a server)). So in the coding, I need to connect to my linux se…
Use awk to create file
I have a file that contain : Mr Q 01629699998 Ms Nhung 011287633 … I would like to use this awk ‘{print “BEGIN:VCARD”;print “Name:”$0;print “TELEPHONE:”$0;print “END:VCARD”}’ file to create this result BEGIN:VCARD Name: Mr Q TELEPHONE:016296999…