Programming :: Working With System Call - Read Output And Parse Values

Dec 10, 2010

I have the following code:
Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
system("ps -ef | grep myprocessname");
return 0; }

When I run this program it outputs the following list of running processes:
Code:
root 10279 10275 0 13:02 ? 00:00:00 myprocessname myvar1=value1 myvar2=value2
root 10341 10337 1 13:02 ? 00:00:00 myprocessname myvar1=value1 myvar2=value2

What I want to really do is instead of writing the output to screen I want to read the output and parse the various values value1, value2 etc. What is the best way to do this?

View 4 Replies


ADVERTISEMENT

Programming :: Using Scripts In System Call In Applicationand Want Script's Output

Sep 8, 2010

I have a script for dd command and i am using it in an application using system() call. Now i want to have the output of the script file (i.e output of dd command) in the application file itself.

View 1 Replies View Related

Programming :: Read A File And Parse A String In C++

Jul 26, 2010

I need to read a file and parse a string. I know in Perl there is the split command. Is there something similar to that in C++?

View 6 Replies View Related

Programming :: Perl Read File And Parse Blocks?

Aug 21, 2010

I am trying to make a perl script which reads data from a file and parse it. The data in the file has the following syntax

Code:
Device Physical Name : Not Visible
Device Symmetrix Name : 1234
Device Serial ID : N/A
Attached BCV Device : N/A
Device Capacity

[Code]...

Each unique record starts with "Device Physical Name". So, I have a set of records within "Device Physical Name". I want to read this set of records starting from "Device Physical Name" and ends up till next "Device Physical Name". Offcourse FS is ":", and I just want to print/or later put info in a csv file.

View 14 Replies View Related

Programming :: Bash Script 'read' With Default Values

Mar 5, 2010

I have a fallowing simple bash script:

Code:
#!/bin/bash
echo -n "Please insert your name: "
read NAME

[Code]....

It works fine, but is it possible to have default values using bash read(1b)? I mean if user is prompter for sex, he just pushes ENTER and by default 'm' is chosen. Or if user is prompted for hometown and he doesn't insert anything, but just pushes ENTER button, 'New-York' sis chosen by default Are such default values possible in bash?

View 1 Replies View Related

Programming :: Using Expr Command To Read Values From Two Different Files?

Mar 20, 2011

I have an assignment where I have to use an expr command to read values from File1.txt and File2.txtHeres the assignment:Create two files.File1 has one line with the value of 5.ile2 has one line with the value of 100.Edit your new file using Gedit or VI and change it so it performs the following actions:Read the values from the files above (file1 and file2)Divide the value from file2 by the value in file1.utput the result of this calculation to a new file called file3. My .scr file is week3prog3_george, in file1 I put var1=5, file2 is var1=20.Then, I put in my .scr file this:

#!/bin/bash
expr File2.txt / File1.txt

It returns an error message stating "non-integer argument."And...how do you point the .scr file to read values from two different files, and the book my school has provided does not contain the info I need.

View 1 Replies View Related

General :: The READ System Call In UNIX?

Oct 29, 2010

mplement the read system call in unix...i want the code for read system call...

View 6 Replies View Related

General :: Parse A Line From A File And Place The Values Into Separate Variables?

Sep 28, 2011

I am trying to parse a line from a file and place the values into separate variables:

input.txt:

Code:

CreateVegaFeed-20110928-before-skip-start

this is the code i have done so far:

Code:

$input_file="input.txt"
INPUT_FILE=`cat $input_file`
for i in $INPUT_FILE

[Code].....

View 14 Replies View Related

Programming :: Implement A System Call For Displaying The System Statistics

Nov 6, 2010

I have been assigned to implement a system call that report the system statistics over all memory which are

Total Pages in Active LRU list
Total Pages in Inactive LRU List

View 1 Replies View Related

Programming :: Variable String File Base - Output File Doest Not Exclude The Values In Grep -av

May 1, 2011

My script.

This is may script:

Code:

Problem: Output file doest not exclude the values in grep -av

View 3 Replies View Related

Programming :: Splitting A File Based On The Values Read From An Input File?

Jul 27, 2010

I am splitting a file based on the values read from an input file. The below one is the script.

1)How do I add the header which is present in the original file to the new split files created?(For eg. pharmacyf conatins header as table column names. The new files created (ODS.POS.$pharmacyid.$tablename.$CURRENT_DATE.dat) are without the header).

2) Also the script is creating 0 byte files for the pharmacyids which are not available in the intial file? Can this be avoided?

for pharmacyf in *
do
tablename=`echo $pharmacyf |cut -f4 -d'.' `
while read pharmacyid
do
grep -w $pharmacyid $pharmacyf >> $OUT/ODS.POS.$pharmacyid.$tablename.$CURRENT_DATE.dat
done< inputfile
done

View 2 Replies View Related

Programming :: Execvp System Call?

Apr 3, 2011

in below program why was new_args[0], rather than the reference the_cmd, passed to the execvp system call?

Code:
/*
A _very_ limited shell program

[code]....

View 2 Replies View Related

Programming :: Read A Txt File With C++ In Linux And Output It?

Mar 15, 2010

i have wrote a long piece of code above with the "main" which is calling openFile( &fout, filename )filename contains the txt name in a form of "data.txt"i wanna read the data from the file and output it into fout for later use.the data in that file is a vector looking interger group.i have the following code:

int openFile( ofstream * fout, const char * filename)
{
ifstream iFile(filename);

[code]...

View 1 Replies View Related

Programming :: Clarification In The Select System Call?

Dec 8, 2010

I have a process that forks, where the childs puts some data of random size and exits while the parent should get the data and does some manipulation.. here I have used a pipe for child to write the data and parent to read the data.. Child simply dumps the data, and the data is of any size even child and parent doesnt know.
I have used select in the parent to see whether there is any data coming on the reading end of the pipe.. if there is a data.. I copy into a buffer.. Im reading the data continusly when the child exits after closing the writing end of pipe. Parent gets blocked on the read part But my question is how parent know the other of pipe is closed when using the select call. In otherwords.. while using select in readfds, how would i know the other end has closed the pipe..

View 2 Replies View Related

Programming :: C - System Call & Error Checking?

Sep 18, 2010

I am trying to figure out how i would go about finding out where system call is made and error checking is not done. I have code below, if somebody can point me in the right direction where system call is made but error checking is not done.Quote:

#include "shell.h"
#include <stdio.h>
#include <string.h>

[code]....

View 5 Replies View Related

Programming :: How To View New Added System Call

Aug 30, 2010

I successfully added a new system call in CentOS Kernel but I don't know where to view it! My kernel version is -2.6.32.5

View 2 Replies View Related

Programming :: Process Of Creating System Call?

Mar 24, 2011

how to create a new system call Linux? what is the process of creating ?my project is to create a system call for displaying owner of a file..where exactly we have to write the system call code? and where are the places need to change ?

View 5 Replies View Related

Programming :: QNX Checksum Call In Cgi Shell Scripting Not Working?

Mar 11, 2011

I have a QNX machine with a slinger webserver running on it. With a cgi script i'm trying to do the QNX cksum call and compare it's output value with a fixed output. When i execute the script at the command line it works perfect, but when execute this script by by the webserver in my browser it doesn't work. Here's my code:

#!/bin/sh
FILE="/home/checkfile"
ORIGCHECK="1712885500"

[code].....

Could it be possible that i'm not allowed to do the cksum call in combination with the slinger webserver?

View 4 Replies View Related

Programming :: Read Console Output From Remote Server?

Jan 20, 2009

when the user clicks a button (assume war application) and the action'system.out.println' a message, how can I *remotly* read this message (read the message from a different computer instead of the server)?when I use the eclipse, I can read it from the console but if I'm in adifferent location, how can I see this message remotely?I'm thinking about remote debugging (JPDA), however, it's very difficult to configure in order to make JPDA run. I tried based on tutorial of google search, bug failed.I wonder if remote debugging can actually solve my problem. If not, is there any other to solve

View 1 Replies View Related

Programming :: Test New System Call Before Compiling Kernel?

Apr 2, 2009

I want to test my system call that be goint to add to kernel, But when i finish compiling kernel, i found my system call code not work. the code i want to return the system time "struct timespec":

/*----------Start of mycall.c----------*/
#include <linux/linkage.h>
#include <linux/time.h>
#include <linux/kernel.h>

[code]....

so i want a method to test the new system call before compiling kernel.

View 2 Replies View Related

Programming :: Sleep Call Causes Whole GNU System To Hang Indefinitely

May 6, 2011

Anyone know the reason why a sleep( ) on a Redhat Linux OS would cause the system to indefinitely hang? It's doing this every 10 or so calls in my program and I have to press the reboot button on my computer. My program is reading from a UDP port that has messages sent to it 20 times per second. When I sleep I assume the internal UDP buffer is getting more and more filled.

View 14 Replies View Related

Server :: Parse The Bunch Of Values Displayed By The Socket Program Into The Php File So That Further It Can Be Displayed In HTML Page?

Apr 15, 2011

How to parse the bunch of values displayed by the socket program into the php file so that further it can be displayed in HTML page

View 1 Replies View Related

Programming :: Make System Call From An Automatically Started Daemon?

Apr 2, 2011

i've written small tool in C which makes measurements on my router (OpenWrt White Russian).

It is working as a deamon. If the tool is started manually, everything works fine. If it is started per script on startup, the following system call doesn't work :

Code: sprintf(command,"/bin/cat /root/%s%s | /usr/bin/ssh -p2222 user(at)host -i /root/.ssh/id_rsa "/bin/cat >> result/%s%s"", apmac, source, apmac, dest);

rc = system (command); the returned rc in this case is 256.

first i thought it is a problems with the user rights for the tool, so i have added +s to it. but that didn't help. as i said, when the daemon is started by hand, the system call works fine.

View 1 Replies View Related

Programming :: Unpredictable Behaviour With Send/recv System Call?

Jul 30, 2011

I am making a library, but I am facing a strange problem while sending data over network using ethernet.

I am sending 39 bytes of the data from one server to slave application but some time slave receives 39 bytes and some time it receives 29 bytes. And when ever slave receives 29 bytes all the memories to which my pointers are pointing get changed. This problem is only when I am sending data from the server to slave, while sending data from slave to server I am facing no such issue.

View 10 Replies View Related

Software :: Script That Call A Java Program That Call A System Command?

Nov 29, 2010

In practice I have a script that call a java program that call a linux system command. The script if I run it, from a shell functions well,so it is not a java problem. The problem come out when i put this script in a crontab schedulation. The result in this case is that java do not execute the system command. I think it depends on crontab

View 4 Replies View Related

Programming :: Poll() System Call Not Returning When The Socket Is Closed Locally?

Sep 29, 2010

we have a multi threaded program on Linux where one thread is waiting on poll() system call with event set to POLLIN, & another thread has closed the same socket fd (which is passed to poll) , but the poll() did not return, is this the expected behavior? From man page of poll we found that the poll should return POLLNVAL if the socket fd is closed, is my understanding correct or is there any bug in the poll()?In Solaris we observed that the poll system call is returning with POLLNVAL if the socket is closed.

View 3 Replies View Related

Programming :: Simple Example Document For Adding A System Call On Fedora 14 Kernel?

Nov 20, 2010

Does anyone have straightforward simple example document for adding a system call on fedora 14 kernel?

View 12 Replies View Related

Programming :: Script To Read Active Squid Logfile And Output Results To Html Based On Conditions?

Mar 12, 2010

Basically the requirement of the script are :

1. need to run like a daemon which will read an active squid logfile in a refresh pattern of 5 minutes

2. calculate the total number requests based on different domains that the client access

3. calculate the total of number of requests based on different domains as well as the turnaround time of these access is more than 5 sec that the client access

4. calculate percentage of item 3 over item 2

5. report the results in html format as follows:

Domain Name Total req Req > 5 sec % of req > 5 sec

6. able to access the results from web browser.

View 8 Replies View Related

Networking :: Create Socat Connection -> Parse -> Output?

Nov 2, 2010

trying to create something that will periodically send messages to a serial device using socat, take the response from the device and format it, then take the formated data and send it out UDP to a specific IP/Port.I tried to do something along the lines ofsocat <readline> <serial device> | parse script/program | socat -u <readline> <UDP:IP:Port> but didn't have any success.socat READLINE,history=$HOME/.cmd_history /dev/ttyS1,raw,echo=0,crnl | format.sh | socat -u READLINE,history=$HOME/.cmd_history UDP:IP:Port

View 2 Replies View Related

General :: Script To Read File And Parse Log Message

Apr 5, 2010

I am working on the script to parsing the specific message like "aaaa" in multiple log files like N1-***,N2-***,N3-***..The script is to find the list of lof files which contains the message "aaaa" and export the list into excel filE.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved