Programming :: C++ Retrieve Output Of Whoami?

Mar 8, 2011

i'm programming a small widget for a panel and need some information from my system. The command on the shell would be whoami to find out which user i am. This information is needed for my widget to set up the title of the widget, the information of the user will be retrieved out of the /etc/passwd (the code works just fine), but i don't know how i can get the information. One possibility would be to create a child process, call whoami with execlp(). But how can i retrieve the output of that process?

View 3 Replies


ADVERTISEMENT

Programming :: Storing Grep Output To Feed Awk To Retrieve Entire Records Matching Variable

Jul 28, 2010

I have two files :

FileA
prot1
prot5
prot9
prot15

[Code]....

What I need to do is to extract from fileB the fields containing only the strings in fileA.

I thought awk could do the job easily with :

Code:
awk 'BEGIN { RS = "###" } /'$variable'/' fileB > output

where variable would maybe be the output of grep from fileA. So can I store the output of grep in a variable to use it afterwards with awk ?

something like that:

Code:
result=`grep prot. fileA` ; awk 'BEGIN { RS = "###" } /'$result'/' fileB > output
but that doesn't work. I'm always getting the entire fileB.

The output of grep get stored in the variable, I verified that with echo. So there is something that I just don't get... It seems to me that the above line should work.

View 11 Replies View Related

Programming :: Retrieve All Process That Use Over 10% CPU Time?

Apr 23, 2010

Writing a bash shell script that list all process that use over 10% CPU time?

View 1 Replies View Related

Programming :: Retrieve A Single String Or Value From /proc/cpuinfo

Oct 1, 2010

I'm trying to retrieve a single string or value from /proc/cpuinfo, but when I try to extract the model (not the model name) the model name comes with it, also it likes to print it twice...

Code:
model="`cat /proc/cpuinfo | grep model | cut -d: -f2 | cut -c1-3`"
echo $model

All i want this to do is spit out the model number once. (I need to pass it to another script)

View 14 Replies View Related

Programming :: PID Retrieval In Tcl / Retrieve The Pid Of The Process (execution Using Framework)?

Jul 13, 2010

I have a test framework written in tcl which i run for 5-6 hours.Now i want to retrieve the pid of the process (execution using framework) as first few line of the script and do some processing.

How this PID retrieval is possible in tcl?

View 1 Replies View Related

Programming :: Input And Output On C++ Programming ?

Jan 28, 2010

As i am new to C++ i couldn't figure out how to input a file and make some change on the file and produce a output file. like this problem i have is.

"Program that processes an input file and produces an output file. The input file will contain lines of data, each containing two floating point numbers. The lines of the output file should contain the two numbers read and their average (with a '$' sign and 2 places after the decimal point)."

View 2 Replies View Related

Programming :: Awk Does Not > Output?

Apr 25, 2010

I have a file with something like** The total time for processing is 1245 seconds *when I doawk 'BEGIN{FS="The total time for processing"} {print $2 } ' fileI get correctly on screen 1245 seconds *but when I try to direct this to a file awk 'BEGIN{FS="The total time for processing"} {print $2 } ' file > outputthenoutput is empty ie the 1245 seconds * is not saved in ...Know why?

View 4 Replies View Related

Programming :: Apache2 Log Output?

May 10, 2010

With the command "tail -300 /var/log/apache2/access.log | less" i can look in the log for the 300 latest visitors. and i wanted to ask if it's possiblle to get that command to run from a php file and if yes how ?

View 4 Replies View Related

Programming :: Compiling Lex Output As C++?

Apr 6, 2011

Lex's (actually Flex) output contains this:

Code:
#ifdef __cplusplus
extern "C" int yywrap (void );

[code]...

View 8 Replies View Related

Programming :: No Output On C Using Gcc Compiler?

Jun 8, 2010

I am trying to learn C Programing and I'm having trouble on the output of my script. my script should count the characters in input but it doesn't give me any numbers..
here's my program code:

Code:

#include <stdio.h>
main()
{
double nc;

[code]....

View 14 Replies View Related

Programming :: Output The Display In C++?

Feb 8, 2010

i am having problem with displaying my text. my text file is displayed in such a way and is called test.......

Code:

Sam Worthington ... Jake SullyasZoe Saldana ... NeytiriasSigourney Weaver ... Dr. Grace AugustineasStephen Lang ... Colonel Miles QuaritchasJoel Moore ... Norm Spellman (as Joel David Moore)asGiovanni Ribisi ... Parker SelfridgeasMichelle Rodriguez ... Trudy ChaconasLaz Alonso ... Tsu'teyasWes Studi ... EytukanasCCH Pounder ... MoatasDileep Rao ... Dr. Max PatelasMatt Gerald ... Corporal Lyle WainfleetasSean Anthony Moran ... Private FikeasJason Whyte ... Cryo Vault Med TechasScott Lawrence ... Venture Star Crew Chiefmore

What i am trying to do is for the program to read "as" and then from there start a new line... thus the expected output is...

Code:

Sam Worthington ... Jake Sully
Zoe Saldana ... Neytiri
Sigourney Weaver ... Dr. Grace Augustine

[code]....

I keep getting the error saying ...

Code:

editmain.cpp.98:error: initializer fails to determine size of 'str'

what does this mean, and how can i be able to format my file in the way i want?

View 2 Replies View Related

Programming :: Output IP Into A File?

May 6, 2010

have a file (called it A) contains;

hostname 192.168.23.65
hostname 10.18.13.253
hostname 10.18.16.253

[code]...

View 14 Replies View Related

Programming :: Output Of The C Program?

Jun 8, 2009

See the first program below :

Code:

This code when compiled gives the following errors:

1. conflicting types for 'fun' at line no: 9

2. previous declaration of 'fun' was here at line no: 3

Why is this happening?

If i modify the above program as shown in the second program below:

Code:

This code when compiled gives no errors.

Why the difference occurs between the first and second program?

View 8 Replies View Related

Programming :: Run Sdl Output On An Other Desktop?

Feb 25, 2011

is there a way in code to tell SDL to be directed to another desktop? This is so I can full screen debug rather than running in windowed mode. By other desktop I don't mean other machine just another workspace.*

* sorry don't know correct term for this it seems in Debian you have 4 you can select from the low right of the desktop, seems to be called desktop 1-2 in ubuntu.

View 1 Replies View Related

Programming :: Bash: Capture All Output To A Log?

Jun 10, 2010

I have a script that generates a bunch of output, including the expansions details provided by: set -v -xI am trying to pipe everything that is displayed to a file, in addition to displaying it on the screen. I've managed to get stderr and stdout into the file, but the expansions are only printed to the screen. Here is what I have so far:sudo -u <user> source my_job.sh |tee my_log.txt 2>&1

View 2 Replies View Related

Programming :: How To Redirect ALL Output To (log) File?

Aug 6, 2010

I am again struggling to make a script work, but hey, it is fun, I am learning new things. I discovered the set -x option which was, for me, like the second coming. Still, what I am not able to do is redirect ALL output to a (log) file, including what is produced by the -x setting. Let's assume a very simple script:
Code: #!/bin/bash
set -x
source="/home/atelier/Bureau/"
ls -la $source and I am running it as . test.sh >> /var/log/test.rmcb.log

The result of ls goes inded into the log file, but the rest still shows on the console where I am running the script: Code: ++ source=/home/atelier/Bureau/
++ ls --color=auto -la /home/atelier/Bureau/ Is there a way to redirect EVERYTHING to the log file ?

View 3 Replies View Related

Programming :: Re-direct The Output Within An Awk Script?

Feb 27, 2011

I need to re-direct the output within an awk script, but not to already known, fixed filenames. The output file names depend on values of the fields. For example (the actual problem is surely more complicated), if, on a given line, the second field is DATA, the third is 1984, I would like to print some information in a file called output_DATA_1984. This could/would change in the following line of the same input file. Such things are pretty easy in bash, put I cannot do it in awk, as I can only find manual references for redirecting output to fixed filenames between double quotes.

View 2 Replies View Related

Programming :: Catching The Output Of 'split'?

Mar 10, 2010

How do I catch the output of split and redirect it to another directory?for example,if my working directory is 'Documents' and I split a file called text.one into 4 files of 100 lines each (xaa, xab, xac, xad), how would I get those split files to be written into 'Directory/subdirectory' instead of 'Directory'?And is it possible to rename those split files so that the split name is suffixed with the original file's name e.g instead of xaa, xab... can they be written as text.one.xaa, text.one.xab..?I've thought about using '>' to send the output to a new directory but it doesn't work; and I've thought about piping the results to another command but I don't know what that other command should be.

View 2 Replies View Related

Programming :: Pipe Output To Gtkdialog?

Apr 5, 2011

For instance, suppose I want to pipe the output of ps -A to a gtkdialog table.

View 1 Replies View Related

Programming :: How To Get Grep Output 0 - 1 And Test It

Apr 7, 2009

I am trying to use a shell script to find a string in a file and do something when found. code...

What should happen is pppd will start in a different process and stream it's output to pppdout. pppdout should be created in the current folder. Then the script should periodically check the pppdout file for the string Script (which eventually will appear, some seconds later) and when found exit the script. Ultimately the script will do something useful when the text is found. However, the output from the program is a repeating: 'scriptname.sh: 12: FOUND: not found'

Where scriptname.sh would be the name of your script and 12 refers to the line with 'done'.

Why does grep not find the text, or at least why deos my script not check the grep output correctly?

View 10 Replies View Related

Programming :: Output Time In Ms From Gettimeofday?

Apr 23, 2010

i am trying to print the time in ms using the gettimeofday function, but on execution the shell gives: Segmentation fault (core dumped) error and leaves the program.. here is the code:

struct timeval time1,time2;
double time_used1;
//get time1
gettimeofday(&time1, NULL);

[code]....

View 3 Replies View Related

Programming :: Pipe Output Of Ls To File?

May 3, 2011

I want to pipe the output of ls in a folder to a file (lets call it test.txt) but when i do so, but when i do ls > test.txt in test.txt there is also test.txt (logical

View 4 Replies View Related

Programming :: Piping Cat Output To Variable?

Jan 10, 2010

New to ubuntu and shell scripting in general... currently I stored some data into a text file. Right now, I would like to output the data from the text file and store it into a variable. Here's what I have so far:

READ_FILE=$(cat $FILE_NAME)

This definitely works and READ_FILE has the necessary data. However, this command will trigger an output to std output and I will see data on the screen, which is not what I want. I tried:

cat $FILE_NAME | $READ_FILE

and various other variants of this. It does not output to std output but neither does anything gets stored into $READ_FILE. I tried:

cat $FILE_NAME >> $READ_FILE

and it arrived at an error of "ambiguous redirect".

View 12 Replies View Related

Programming :: The String H4x0rz Does Not Come Up In The Output?

Feb 28, 2011

why isnt this working as i am expecting:

Code:
[schneidz@hyper temp]$ cat example.tmp
hello world

[code]....

View 1 Replies View Related

Programming :: Using Sed To Modify Command Output?

Jun 13, 2010

The output of a command changed and I need to extract the data and print it out in a different fassion:

Code:
abcd1=aaaa xx
abcd 2 aaa xx bbb
abcd2=aaaa xy
ab 2 xx aaa bbb ccc xxx
should be transformed to:

[Code]...

Currently I used sed "search1|search2|search3" to get the lines that need to be transformed. But I also need to search for substrings in those lines and I need to print those substrings in a specific order together with other characters. How is this done with sed?

View 7 Replies View Related

Programming :: Xargs With Output Of Find

Jul 15, 2011

I'm testing some multi-plat java code and I'm getting a bit frustrated with the Linux tests. I need to run the command:
Code:
$ java -jar /home/developer/TCO/TabletComicOptimizer.jar <file> <args[]>
against all the files that match a specific criteria. I've tried various find syntax and I can't seem to get it right.

Normally I would just create a bash script and populate the results of find into an array and then just enumerate the collection but in this specific case I want to demonstrate this operation at the bash terminal.

I've tried things like:
Code:
~/TCO $ find . -type f -iname "*.cb[rz]" | xargs java -jar TabletComicOptimizer.jar {} 1200x1800 ;
Thinking that the {} is the substitution for each file returned by find but it's not working. How do I execute my java program against each result in the find operation?

View 6 Replies View Related

Programming :: Reading File - Output From Xrandr -q

Jul 24, 2010

Code:

I'm trying to make several files: each named after the display and containing resolutions. But for some reason I get null when trying to read lines.

View 2 Replies View Related

Programming :: Echo Two Command Output In The Same Line?

Jan 25, 2011

I try to write script and echo two command at the same line .

echo "A"
echo "B"

How can I pipe above two command at the same line in text file . So, in the output text file , you can see below ? Code: A B not Code: A B

View 4 Replies View Related

Programming :: Pipe Output To 2 Files But Not STDOUT?

Mar 24, 2011

I want to have the output of a program go to 2 different files but not going to standard out. Is there a way to do this in bash? I know that in Z shell its really easy. omething like: Code: echo "test" >> file1 >> file2 Would work. But in Bash it doesn't seem that easy. I know that tee will send the output to 2 files but it also sends it to STDOUT.Something like:Code: echo "test" | tee -a file1 file2 Would put the word "test" in file1, file2, and STDOUT. Is there a way to just send the output to file1 and file2?

View 2 Replies View Related

Programming :: Bash - How To Control Output Style?

Aug 24, 2009

For example,I have three paragraphs,as following:

I want to output it as following:

View 2 Replies View Related







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