Programming :: Script For Executing A Program And Doing String Comparison

May 6, 2009

I am fairly new to linux still and I'm currently trying to write a shell script (which I have never done) that is supposed to run the xrestop(like top) program. What I want to do is execute the program and check the identifier column to see if a certain program is running. If it is running I want to strip the data from that row of the terminal say every 5 seconds or so and put it in a text file. Is this going to be a complicated thing?

Heres a list of the columns when you run xrestop program res-base Wins GCs Fnts Pxms Misc PxmMem Other Total PID Identifier.

View 9 Replies


ADVERTISEMENT

Programming :: String Comparison - [: =: Unary Operator Expected?

Nov 23, 2010

I would like to compare the nmlookup result of IP's stored in the file ips with a list of PC names stored in the file pcs.

Code:
for line in `cat "ips"`
do

[code]....

View 2 Replies View Related

Programming :: String Comparison - Get Regular Expression To Work In If / Else Statement?

Jun 29, 2010

how do I get this regular expression to work in an if/else statement? This is just a little script for learning BASH. don't be too harsh.

This script will test if a certain number of files with 1-4 in their filename exist and print their filename. An error message will be printed if not.

#
for i in `ls file[1-9]`
do
if [[ "$i" == *1-4 ]] ; then
echo "This file, $i, ends in a number between 1-4"
else
echo "Error, this file, $i, does not end with a number between 1-4"
fi
done

I get this error. ./file_test.sh: 13: [[: not found

View 2 Replies View Related

Programming :: Why Fork Is Executing The Program Twice From Start

May 25, 2011

I am learning about OS and I wrote this simple forking program... Here's the code..

Code:
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>

[Code].....

How can it print the first statement, that is BEFORE the fork() statement twice?

I am running Natty 11.04 btw..

View 8 Replies View Related

Software :: Awk From End Of String - 3 Position Comparison

Oct 3, 2010

I would like to check if the 3rd character from the end of a string is a d or p using awk and the field seperator would not help for this problem, i.e.

Code:

View 4 Replies View Related

Programming :: Uncertain Output Of C++ String Concatenation Program

Sep 15, 2010

The below program is giving unpredictable and wrong output when I compile with g++ under Ubuntu OS , tried with the complier avilable with Ubuntu 8.04 and Ubuntu 10.04 LTS.

But it works fine when complied and ran Redhat g++ 3.4.6

View 5 Replies View Related

Programming :: C++: Program Crashes On Exit On Std::string Destructor?

Sep 24, 2010

i am wondering why the following simple code causes a segfault on exit,when the std::string destructor is called.

Quote:

#include <iostream>
#include <string>
using namespace std;

[code].....

I guess the memset messes with some internal std::string's data structures/pointers. I personally am anti-memset,and always avoid them.

View 4 Replies View Related

Programming :: Copy String A To String B And Change String B With Toupper() And Count The Chars?

Oct 22, 2010

copy string a to string b and change string b with toupper() and count the chars

View 3 Replies View Related

General :: String Comparison Error "user@host:~/scripts> ./check_BRK1E.sh BIP1284I: Broker 'BRK1E' On Queue"

Jan 31, 2011

Here's my code on SLES v11.

#! /usr/bin/ksh
MQSILIST=$(mqsilist)
RUNNING="BIP1284I: Broker 'BRK1E' on queue manager 'BRK1QME' is running. BIP8071I: Successful command completion."
echo $MQSILIST
if ["$MQSILIST" == "$RUNNING"]; then
echo "Running."
fi

Here's the error I receive. user@host:~/scripts> ./check_BRK1E.sh BIP1284I: Broker 'BRK1E' on queue manager 'BRK1QME' is running. BIP8071I: Successful command completion. ./check_BRK1E.sh[8]: [BIP1284I: Broker 'BRK1E' on queue manager 'BRK1QME' is running. BIP8071I: Successful command completion.: not found [No such file or directory]

View 1 Replies View Related

Programming :: Pthread - Take String From The Command Line And Creates A Thread To Print The String

May 3, 2011

I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.

[Code]....

One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?

Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.

View 6 Replies View Related

Programming :: Comparison Between Pointer And Integer

Jul 6, 2010

I'm trying to write a simple program that lists a menu and then asks you for your decision, and you can answer with a number or the name. However, I don't know how to add the second options (name).

View 14 Replies View Related

Programming :: Getting A Comparison Operator To Work?

Feb 8, 2010

I'm very new at Bash scripting and have a bone head issue that I'm trying (and failing) to resolve. I cannot get this one IF statement to work, it seems the comparison operator does not think the resulting number from the $b*$c+$b operation is an integer even though it is a number. Below is a small proof of concept script with the bit I'm having trouble with.

Code:
#! /bin/bash
a=800
b=700
c=.15
if [ "$a" -le "$(echo "($b*$c+$b)"|bc)" ]

[Code]...

View 6 Replies View Related

Programming :: Operator For Floating Point Comparison?

May 10, 2011

I know it is wrong to use the "==" operator to compare the equality of two floating point numbers. Logically it would seem that if the "==" operator is not usable for floating point comparison, then the "<=" operator would also not be usable. Is this true? The lack of google search results on this topic made me think that it must be true. If that is true, then is it true that the only way to compare floats with <= or >= is with something like the code below? Code: bool smaller_than_or_equal(float a, float b) {

if ( fabs(a-b) < EPSILON){return true;}
else if (a < b) {return true;}
else {return false;}

} I think this is a general question, but if specifics are necessary, I am using the C++ language to code at the moment.

View 5 Replies View Related

Programming :: Comparison And Breaking Out Of Loop Java?

Oct 10, 2010

my issue is that the when i put in the correct input its going into the loop like i put in incorrect input and wont break out of the loop even with the correct input entered

Code:
import java.util.*;
import javax.swing.*;

[code]...

View 3 Replies View Related

Programming :: Using Sed Replace Line Containing Particular String By A Single String?

Oct 16, 2010

I have a set of lines as ahown below:

Leon went to school
Leon came back from school..
Leon had dinner...

I have to replace the line containing "dinner" by a single string LUNCH...

View 2 Replies View Related

Programming :: Creates String Suffixes Out Of A Reference String?

Feb 25, 2011

I need to creates string suffixes out of a Reference string. for eg. suffixes of abcdefg will be

1)bcdefg
2)cdefg
3)defg
and so on...

create an array of pointers to point to the first few characters and then use that pointer to print the rest of the string.But when i print using the pointer i get GARBAGE values! shudn't std::cout<<ptr[w] print the string following the char it is pointing to? why do i get garbage values?

View 9 Replies View Related

Programming :: C - Put A Specific Arbitrary Part Of A String Into It's Own String?

Apr 18, 2010

So if I'm given a location of a file like:

How can I just take the type of the file at the end? I know I can use strrchr() for a period to get the pointer to the period just before file type. Is there a build in string function that will just take the rest of the string from a certain point on forward in the string? I know it wouldn't be much work to make it myself, but I figured I would find out if it already existed before doing it.

View 9 Replies View Related

Programming :: Convert String To Integer Back To String C++ ?

Mar 13, 2010

Code:

The error is:

Code:

What I want to do is take input of ip4 as a string, convert it to an integer to add 1 to it, then reconvert it back to a string. Its not working.

My full code is:

Code:

View 1 Replies View Related

Programming :: Bash Scripting With File Date Comparison?

Mar 23, 2011

I need to be able to compare a file date with system date and delete files older than 30 days.

the file name is basically
error_log.03222011

of course the extension is the date the file was created.

Oh and before i get hammered I looked everywhere but am unable to make sense of what I found.

View 3 Replies View Related

Programming :: Bash Time Comparison Within A Fast Moving Log?

Jun 1, 2010

I have a bash script that is tracking ERROR connections (running in a cron every 15 minutes), sometimes the errors are true and are not connecting. But most of the time, the disconnects/reconnects are between 30 seconds are sending out false positives. I am looking for a time comparison code to pick out the 30 second disconnects and know that this is and "ok" error. Here is a section of the log with timestamps, errors, etc.

Tue 2010-06-01 22:01:30 ERROR [DataBufferSendService] 172.31.0.1:8016 caught exception: [NetworkAPI] Exception: [SocketStream] socket error
Tue 2010-06-01 22:01:32 ERROR [DataBufferSendService] 172.31.0.2:8016 caught exception: [NetworkAPI] Exception: [SocketStream] socket error
Tue 2010-06-01 22:02:00 INFO [Client] 172.31.0.1:8016 connecting to 172.31.0.1 on port 8016
Tue 2010-06-01 22:02:02 INFO [Client] 172.31.0.2:8016 connecting to 172.31.0.2 on port 8016

View 8 Replies View Related

Fedora :: Allow Executing File As Program?

Apr 18, 2011

i have many text files in my directory and when i click on them to open them os treat it as a runnable file any says display or run or run in terminal ... i want to pick up recursively the tick of "Allow executing file as program" for all files.

View 2 Replies View Related

Ubuntu :: Executing Any Program After Download?

Sep 4, 2010

After downloading any program thats in ubuntu or uses wine to run before i can run it i've got to allow it to execute, is there a workaround for this? Im using 10.04 ubuntu desktop

View 1 Replies View Related

Ubuntu :: Allow Executing File As Program?

Apr 22, 2011

On the `Install Properties` Menu , I am not allowed to check the: Allow executing file as program...

View 2 Replies View Related

Programming :: Assigning Custom String To Std::string In C++?

Oct 12, 2009

I've been given a custom-made string class which handles string, wstring and bstr. It has a number of methods and assignment operators to convert to and from different types. The app I work on compiles happily in VS6 and VS2008, but when trying to compile in Redhat (version 4.1.1 in Redhat 5.0)

[code]....

View 4 Replies View Related

Programming :: How To Check If All Letters Of One String Are In Another String?

Nov 11, 2010

I have the following two type of strings1: A/D2: A/C/DI am trying to write a subroutine to check whether all of the letters in string 1 appears in string 2. If yes, return true. If not, return false. In the above example, all the letters (A and D) in string 1 are also present in string 2, so I return true.

View 4 Replies View Related

Ubuntu :: One Of My Program Is Not Executing - Fgsd Crashed

Jun 7, 2011

I m using ubuntu 10.04. I have install flightgear Scenery designer(fgsd) and it executed successfully, but during working on it I selected any option of it and fgsd crashed. After that it is not getting execute. Throwing following error on console. buffer overflow detected ***: fgsd terminated

View 1 Replies View Related

General :: Executing A Program From Command Prompt?

May 27, 2011

I'm trying to run an application from the command prompt. I've set the path in .bashrc. My executable file and all other files needed by it are saved in the same directory as the path. When I enter the executable name to run it, I get an error message saying that the command is not found.

View 14 Replies View Related

Programming :: Shell Script Comparison For Two File(text) Character Wise?

Mar 1, 2010

I need to write a shell script which can compare two files(text files) character wise. eg. underscore is space.

------FILE 1---------------
A_B_C
D_E_F
G_H_I

[code].....

Actual problem: I need to write a shell script which can give me difference character by character not by line (using comm)

View 4 Replies View Related

Ubuntu :: Can't Mark Allow Executing File As Program / Resolve This?

Oct 23, 2010

Yesterday,I upgraded to ubuntu 10.10
then when i try to mark allow executing file as program it unmarks itself although i used it on ubuntu 10.4

View 9 Replies View Related

General :: Executing PHP File And Read Output To Program

Jun 29, 2011

I'm using Ubuntu and I'm programing with eclipse CDT. My goal is to execute a php file and read the output to my c++ program. To do so I thought I should use fork(), dup2() and execl. When in shell, the call "php myscript.php" worked just fine, but when in c++ I tried:
execl("usr/bin/php", "php", "home/geiger/workspace/SemiServer/server_content/myscript.php", NULL);
And it didn't work (the process wasn't terminated and I got no output). I tried different version of this call, like losing the "php" string and/or drop "home/geiger" from the path string, to no better result.

View 1 Replies View Related







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