Programming :: How To Extract Output Ulimit Under Popen
Jan 30, 2011
A strange question, I guess. I'm running processes called from a c main program. The calling is performed (for now) as: FILE * res=popen(ulimit -t 1; prg args); So I can read the stdout of the process as a file and analyze it. The time limit is important for me.
2 questions:
1. How do I get to know if the process terminated on its own or by the ulimit?
2. How do I limit to times that are less than 1 sec (I have many of those).
I know that setrlimit exists, just before I change my whole approach I wanted to see if I can deal with these things from the outside.
I wrote this because i was able to use openmpi to run mpirun on my 12-core workstation rather happily since day 1 I setup the system a few months ago. Yesterday when I tried to run a big job under mpirun, the job crashed rather quickly, the error message was something like mpirun process exited blah blah with signal 11 (Segmentation fault). Interestingly (or annoyingly) a job required less memory ran okay.
Since I never had this problem before, I thought it was the hardware failure. I called my IT guy to explain the problem and he is kind enough to suggest to put a line
ulimit -s 40960
in my .bashrc. And it works! But I have no clue why mpirun misbehaves out of a sudden, and that ulimit setting solves the problem completely. I would like to learn from this incident.
Is it ok to read a process output with fgetws? I get segmentation fault when I try that.
Code: #include <iostream> #include <cstdio> int main() { wchar_t line[4096];
[Code]...
I can read the output from the process if I use fgets instead of fgetws.But I am getting special characters in the output for some commands, that is why I wanted to try with fgetws.
What I need to do is to extract one complete column (file size) from the output of ls -lS but while doing so in some rows I have a single space but in some other rows I have 2 or 3 spaces like some file sizes are different with 30 bytes 400 bytes and some 4000 bytes. So when I extract the output of ls using | cut -d ' ' -f5 i get the value which has only one space i.e. I get 4000 as output because 400 has 2 spaces seperated and 30 is 3 spaces separated. So how to get the file size column from the ls output?
i using Popen() sys call in my code to run a script. i know it will return file pointer. but requirement is some how i need to get return status of process which is invoked by popen. there any possibility to get its status, if so please let me know. FYI i cant use system() here becoz of some limitations
I need to extract a price from a string, this may vary in the future so it may be 12.99 or 14.99. i thought a sed command might crack it and i need to write to a file:<td><b class="priceLarge">?6.99</b>I need to extract the price 6.99(with no ?)so extract anyhting between "> and </B> and write it to a file such as tmp1.txt .
I am trying to extract a web page via Google for processing. I am able to create a proper query and test it using cut/paste into the address bar of my firefox browser.
When I attempt to extract the page with wget: wget -O - -q "$query" I do not see the information that is present when I used the browser.
I am trying to extract 2 numbers from a same file and my goal is to print them both in another file, on the same line, separated with a space. I have to do that for 20 files and I would like to have therefore 20 lines like this in the output file. It would look like this :
And I did this by running a bash script with the following content :
Code:
#!/bin/bash ls execution$1$2*.* | while read filename do cat $filename | grep -e "Total aborts:" | cut -d " " -f3 >> abort$1$2.dat done
$1 and $2 are just strings to identify the different files I want to consider in this loop. This script works well to extract a number which is the 3rd field of a line starting with "Total aborts:".Now, how could I change this script to do what I mentioned above (i.e. extracting two numbers from two different lines) ? The second number is the 3rd field of a line starting with "Total throughput:"
I have this string ./DAT000728-652523058.job.I want to extract the no between DAT and - sign. I want 728. I dont want 000728.echo ./DAT000725-560162365.job | cut -d'T' -f2 | cut -d'-' -f1 I am getting 000728.string can be ./DAT326822-652523058.job also. then i need 326822
I have many files in a folder from which I need to extract some contents, these are basically text files wich have individual lines with (i.e)
name: john address: whatever phone: 123456
Some caveats
1. Sometimes a line might be missing.
name: johnn phone: 123456
2. Lines are not in the same line-numbers across the files I did try some things with awk based on google searches but I couldn't extract the data of each file into a single line (this is the ultimate goal):
john,whatever,123456
I don't have knowledge other than having put some bash scripts together for backup jobs, so I am open to install anything that could to pull this off.
I'm trying to create an application that monitors, among other things, what site the user is currently viewing. I would like to know if there is any way to get the current URL from the Firefox's address bar on a Linux machine. I know that under Windows I can use the DDE server approach, but under Linux this task is proving very tricky. I've considered an approach involving an extension to Firefox, but this would require the user to install the said extension himself. Which is not something I want. If an extension can be installed by a different program's installer than that could work, but I don't know if that's possible or not.
The idea is to make a website to check the availability of domains and it works but its not pretty yet. Below is what i have till so far:
## this is the API from my domain registrar. <?php $client = new SoapClient('http://api.sync.com/?wsdl'); ## I have a search box that sends the request to this page $var = $_GET ["s"];
## remove the most common subdomains from the request. $var=eregi_replace("www.", "", $var); $var=eregi_replace("mail.", "", $var); $var=eregi_replace("ftp.", "", $var); $var=eregi_replace("pop.", "", $var); $var=eregi_replace("smtp.", "", $var);
## remove any TLD extension from the request. $split = explode(".", $var); $main = $split[0]; $arraysize = sizeof($split); for ($x=1; $x<$arraysize; $x++) { $tld .= "." . $split[$x]; } ## login to the API $paramLogin = array('handle' => 'randall', 'password' => 'password');
Result Login: Array ( [code] => 200 [message] => Login succesful ) array(3) { ["code"]=> string(3) "200" ["message"]=> string(20) "Domain not available" ["result"]=> object(stdClass)#236 (1) { ["status"]=> string(5) "TAKEN" } } bool(true) array(3) { ["code"]=> string(3) "200" ["message"]=> string(16) "Domain available" ["result"]=> object(stdClass)#232 (1) { ["status"]=> string(4) "FREE" } } bool(true) ?> ## till so far it works
What I need to do is to make this ugly looking reply in to something more readable, basically if TAKEN print occupied and if free print its yours to grab. I have been struggling with the in_array function but i'm not getting anywhere close in getting it to work.
I am trying to get the metadata out from an image file in python. I have tried using PIL but it does not give me the data I am looking for (mostly just got a bunch of hex code) and I have no idea how to use ImageMagick, the python module is poorly documented and I can't find any examples on the net.The info I need is stuff like camera model, if flash was used, focal length, exposure time, date, etc.. pretty much the same info I get when I look at the "Image" tab on properties in Nautilus on Ubuntu.
What I am doing is writing a script that will iterate through a lot of pictures and put all this metadata into MySQL. I chose python since it is simple and I am familiar with it. But I can't find a good way to get that metadata from within python.
I have a small bash/awk program that extracts the date/time/size of thousands of email headers. I'm trying to also extract the last "Received from:" string from these email headers which will give me the senders email server. on extracting the last occurrence of this string, and printing the information after it?
im trying to find a way to extract the phrase between the words Connection and is (ie the underlined words below). Can we use awk to do this? How? Is it the best command to use?
Code:
[06:25:00][i] Connection at Plant A is live [06:25:00][i] Connection at Building_C is not live [07:25:00][i] Connection at Terminal D is down
There is always one occurrence of € in each line. I want the numeric value that precedes this € occurrence. The random text (before and after) may contain numbers too, so the € may be important to parse, in order to correctly identify the number to return. The last character that precedes the number to extract is always a ">" (coming from an HTML tag).
I have a requirement where I want to extract the full name of the process running in my box. I tired various options of ps. The wide option gave me the full command but that contains command, the interpreter and also the arguments passed.
Code:
XX XX XX XX XX XX /usr/bin/sh /path/to/exe/myexe.sh arg1 arg2 arg3.
Is there any way from ps or any other command I can extract the full name of the command
I have a huge file which has 450G. Its format is as below
x1 50020 A 1 x1 50021 B 8 x1 50022 C 9
[code]....
Now, I want to extract a subset from this file. In this subset, column 1 is x10, column 2 is from 600000 to 30000000. I wrote the following perl script but it doesn't work:
I need to extract the Info from the RC column for the first 4 players of liverpool. The test code i have does the same,but can anyone show me a better way of doing it.I could do it easily with gawk -F"|" and print the respective column,but i need to do this in perl.
I am trying to write commands that extracts the height and width of a video file via ffmpeg. I have the following working so far:
This gives the following answer in widthxheight format with an extra , 720x480,
How can I instead run 2 separate commands that give me height and width separately? I want some command to give me 720 and another command to give me 480 and I dont need the x or the ,
If you need to know this is what ffmpeg -i videofile.mov 2>&1 gives as output
I'm trying to extract specific lines from a flat file. I need lines that fall within a range of coordinates. The -F can be either ! or = If the line is in this set range I need all of the data on that line. ranges lat 36 to 39 and longitude -74 to -84
I would like to extract debug information but I have some problems. For example, I have a executable a.out...
Quote:
nm -f sysv a.out | grep ".global_var" >vars.txt
With this command I extract all my variables. All of them are in .global_var section, and it give me follow information:
Quote:
CAN_station_n |08073258| D | OBJECT|00000001| |.global_var CONTROLend |080732a7| D | OBJECT|00000001| |.global_var
[code]....
Well, I have only address of my vars, but I would like to know type var or struct of the variables. With dwarf dump I have all of information, but it is a mess...
Im trying to extract the href of a <link> tag from a html page however as some links contain further preferences I seem to be unable to extract them, do you have any idea how I can write this: Link:
i just want the characters which are to the left of the first .(dot) in FQDN name. I could get it using substr and split function,but how do i get it through regex.
Now I would like to create a third file which contains only those packages which are present in package-a.txt but NOT in package-b.txt. The file should look like this:
Code:
package2 package4
Note: The world "install" is also to be removed for all packages. Using diff command I could get something like this: