Programming :: C: Testing Multiple Consecutive Array Values Concurrently.?

Nov 22, 2010

Basically, I am provided with a file "temp.dat" with 30 high temperatures (integers) in it. The program is supposed to read them in and compute/print the average. Then it is supposed to print the temperature of each day and, in addition, display a + by each day that is over the average, but only if it is above the average high for three or more consecutive days. This is the part I am stuck on. I'd appreciate any tips that would point me in the right directionFull disclosure: This is a school project. Code:

Code:
#include <stdio.h>
#include <stdlib.h>

[code]....

View 2 Replies


ADVERTISEMENT

Programming :: Shell Script To Convert Values On Successive Lines Into Consecutive Ranges?

Jul 7, 2010

I have a series of input files formatted like this:

Code:

RTREVF, KOG3266 = 111
RTREVF, KOG3294 = 130
RTREVF, KOG3295 = 177
WAGF, KOG3307 = 107
JTTF, KOG3320 = 174

Each line represents a portion of a data matrix. I want to convert the numbers after the "=" to the range of that partition in the matrix such that the output file looks like this:

Code:

RTREVF, KOG3266 = 1-111
RTREVF, KOG3294 = 112-241
RTREVF, KOG3295 = 242-418
WAGF, KOG3307 = 419-525
JTTF, KOG3320 = 526-699

View 5 Replies View Related

Programming :: Extract Values From Array PHP

Jul 2, 2009

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');

## match the domain with any possible TLD
$varcom = $paramAvailDomain = array('sld' => $main, 'tld' => 'com');
$varnet = $paramAvailDomain = array('sld' => $main, 'tld' => 'net');
$varorg = $paramAvailDomain = array('sld' => $main, 'tld' => 'org');
$varbiz = $paramAvailDomain = array('sld' => $main, 'tld' => 'biz');
$varinfo = $paramAvailDomain = array('sld' => $main, 'tld' => 'info');
$vareu = $paramAvailDomain = array('sld' => $main, 'tld' => 'eu');
$varnl = $paramAvailDomain = array('sld' => $main, 'tld' => 'nl');
$varbe = $paramAvailDomain = array('sld' => $main, 'tld' => 'be');
$varde = $paramAvailDomain = array('sld' => $main, 'tld' => 'de');
$varcouk = $paramAvailDomain = array('sld' => $main, 'tld' => 'co.uk');
$varorguk = $paramAvailDomain = array('sld' => $main, 'tld' => 'org.uk');
$varname = $paramAvailDomain = array('sld' => $main, 'tld' => 'name');
$varmobi = $paramAvailDomain = array('sld' => $main, 'tld' => 'mobi');
$varin = $paramAvailDomain = array('sld' => $main, 'tld' => 'in');
$vartv = $paramAvailDomain = array('sld' => $main, 'tld' => 'tv');
$varcn = $paramAvailDomain = array('sld' => $main, 'tld' => 'cn');
$varws = $paramAvailDomain = array('sld' => $main, 'tld' => 'ws');
$varnu = $paramAvailDomain = array('sld' => $main, 'tld' => 'nu');
$varbz = $paramAvailDomain = array('sld' => $main, 'tld' => 'bz');
$varcc = $paramAvailDomain = array('sld' => $main, 'tld' => 'cc');

## this requests the domain.COM and domain.NET
$varcom;
$varnet;
?>
<div id="content">

## below prints the result
<?php
print "<html><body><pre>";
$result1 = $client->__soapCall('Login', $paramLogin);
echo "<b>Result Login:</b>
" . print_r($result1, true);

$result15 = $client->__soapCall('AvailabilityDomain', $varcom);
$resvarcom = var_dump($result15, true);
$result15 = $client->__soapCall('AvailabilityDomain', $varnet);
$resvarnet = var_dump($result15, true);

print "</pre></html>";
?>
<?php

## the returned array looks like this

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.

View 2 Replies View Related

Programming :: PHP Array - Possible To Get More Than Two Values Per Entry?

Jun 13, 2009

I created a class which has to return an array. My problem is I need to return 3 entries per record for example:

Code:
array(
"2009-06-13", "John", "Doe";
"2009-06-13", "Paul", "Simon";
"2009-06-12", "Frank", "Herbert";
);

Can this be done? What is the syntax? Where is the documentation? If this can't be done, How would you return this to a class without using a DB?

View 3 Replies View Related

Software :: Bash - Indirect Array Reference To Array With Values Containing Spaces?

Jun 4, 2010

This _almost_ works. I just can't quite get it to honor the spaces.

Code:

#!/bin/bash
profiles=(
PROFILE_ONE
)
PROFILE_ONE=(setting1 "setting number 2")

[code].....

View 9 Replies View Related

Programming :: Parsing And Storing Multiple Values Using 'awk'?

Jan 24, 2011

I have a variable in which the data is stored as below:

variable_test=0m0.001s 0m0.001s 0m0.001s 0m0.001s 0m0.001s 0m0.001s .....an so on.

There are lots of values in format like "3m1.057s" are stored in variable_test separated with an space between two such values. For exapmple, value is "3m1.057s" I need to save different parts of a value in three separate array variables such as the

var_hour=3
var_min=1
var_sec= 057

tell if this can be done using "awk". A "WHILE" loop might be used to separate and store theses values I guess?

View 1 Replies View Related

Programming :: MySQL And PHP - Table Column With Multiple Values?

Dec 1, 2008

I am writing a script to mine data from my game server logs which are going to mysql. My first question is syslog-ng is sticking $msg into one colum it self, $msg tends to be a long string here are a few examples:

cn name team frag death flags role host.
0 Maik CLA 2 0 0 normal *.70.233.118.
1 lizardncd RVSF -1 3 0 normal
[*.22.247.40] lizardncd fragged Maik.

And they are not always in the same format, How could I parse this data to do something useful, like creating a user stats page with frag counts and flag counts. Should I create a script that runs in a cronjob that parses this data to a new table maybe once a day. Even then the $msg string value is random and I am thinking in terms of awk.

Second. I would like to keep track of what ip's are using what nicknames. Kinda in the sense of and ip associated to a array of names that have been used on that ip address so I can keep track of users. How would this work logically with a mysql db, could a column allow multiple values, then loadable into an array, which then can add, remove, and store to mysql.

View 1 Replies View Related

Programming :: Grep Multiple Values In Single Pass Through Log File?

Nov 13, 2010

I have a huge binary log file. There are lets say 4 id's that I want to find in a log file. I know that those 4 id's will be present in the log file and I also know in what order they will be present. I want to find 1st id from the log then 2nd id and then third id and so on..

Simple/inefficient solution is: Loop through the id's and then grep in the log file. Problem with this solution is for each id grep will search from the beginning of the file.

Better/efficient solution would be: Sine I know the order in which id's will be present in the log file. Loop through id's, grep 1st id and then move on to grep 2nd id and so on...this way I can grep all id's in one pass. Is this solution possible ?

I have 500000 + values to find in log files and I have to find efficient solution for it.

View 2 Replies View Related

Server :: Mount A Drive Or Partition On Multiple Servers Concurrently?

Jan 19, 2011

I am tasked with setting up 3 out of the 6 servers and dividing up 500GB of space in the most efficient manner amongst the 3 servers. The space is in a pool which can be assigned to virtual drives. Each virtual drive can be assigned as disk0 or disk1 and so on to one or more servers. They'll be running CentOS.

On the second try I came up with this scheme:
shared sda1 -- /boot (ext3)
shared sda2 -- /home (ext3)

[code]....

View 5 Replies View Related

Programming :: Sed Regex Get Multiple String Match In Array?

Apr 8, 2011

I have a sed match that matches for certain string of a regex expression:

Code:
tname=$(echo "$contents" | sed -n 'some pattern')

How do I match for multiple strings in the $contents and return them as an array? for example

Code:
contents="this is a text, just to match patterns, here is another text to be matched"
the sed func would be able to recognize both "text"s, but only one is outputted?

Possible to put it in an array? so ${bar[0]} gives one and ${bar[1]} gives another

View 3 Replies View Related

Programming :: Allow Interleave Output When Run Commands Concurrently?

Feb 23, 2011

I am working on the shell using c language. I just would like to ask when I run some command in the backgrounds, how can I allow interleave out? I want to the output like this:

shell> command1
shell> command2 &
shell> command3

[code]...

View 3 Replies View Related

Programming :: Making Sure Only One Instance Of Script Runs Concurrently

Dec 11, 2010

I need to write a shell script that will be run from cron every minute or so. The script will use rsync to keep some folders across several machines in sync. I am very new to shell scripting so some answers might seem obvious but they are not to me:

1. How do I check at the beginning of the script if the script is already running and abort if it is? I saw that most processes use a PID file for that but I am not sure this is the right case for that and in fact how to do it exactly

2. Assuming the list of target machines/dirs to sync are supposed to come from some config file. How should I code that? Just use the normal shell tools that I already know (cut etc) or is there a better way?

View 6 Replies View Related

Programming :: Sed/awk: Three Consecutive Blank Lines In A File - How To Delete Two Of Them

Jun 16, 2010

I have a file with three consecutive blank lines. I want to delete two and keep one.Also, if anyone could direct me towards a guide on regular expressions particularly as they apply to sed, I would be grateful. I am having a hell of a time figuring out the syntax.

View 8 Replies View Related

General :: Bash + Reading Values (numbers) From A File And Storing Them Into An Array?

Nov 4, 2010

I have to read a couple of numbers from a random.txt file. In this .txt file there are random numbers. They are separated by a space. Example if you opened test.txt:

test.txt :1 6 1 3 6 8 10 2 4

I would like to read those numbers using CAT and store them into an array:

numlen=${#num[*]} - (must be like this because it is a part of a larger program)

View 5 Replies View Related

Programming :: C Realloc Resize Array / Delete And Add Information Into The Array?

Mar 6, 2011

I am trying to dynamically delete and add information into the array "blah"

Code:
int blahsize = 1;
char** blah = (char**) calloc(blahsize+1,sizeof(char*));
Adding information:
Code:
blah[1]=stuff1;
blah[2]=stuff2;
code....

View 2 Replies View Related

Programming :: Convert Short Array To Char Array?

Jun 7, 2010

I have trouble converting a short array to a char array

Code:

short pShort[4] = { 0x41, 0x42, 0x43, 0x44 };

How to convert this to a char array?

View 4 Replies View Related

Red Hat / Fedora :: Bash - Echo Multiple Numeric Values On One Line

Aug 9, 2009

I'm trying to get multiple numeric valued version information into a variable, all on the same line. I want for example $VERSION=3.1.0.01.002. I'm trying to pull seperate values from the file named version.properties, wherein the file contains;

patch.rel.num=0
sqa.num=01
major.rel.num=3
build.num=002
minor.rel.num=1

So I have the following script:
#!/bin/bash
BUILDVERFILE="version.properties"

PATCH=`grep "patch.rel.num" ${BUILDVERFILE} | awk {'print $1'}`
SQA=`grep "sqa.num" ${BUILDVERFILE} | awk {'print $1'}`
MAJOR=`grep "major.rel.num" ${BUILDVERFILE} | awk {'print $1'}`
BUILD=`grep "build.num" ${BUILDVERFILE} | awk {'print $1'}`
MINOR=`grep "minor.rel.num" ${BUILDVERFILE} | awk {'print $1'}`

P=`echo $PATCH | tr -d .=[:alpha:]`
S=`echo $SQA | tr -d .=[:alpha:]`
MA=`echo $MAJOR | tr -d .=[:alpha:]`
B=`echo $BUILD | tr -d .=[:alpha:]`
MI=`echo $MINOR | tr -d .=[:alpha:]`

VERSION=$MA.$MI.$P.$S.$B
echo $VERSION #

I end up with the value of .002 ?? Seems like it's only getting the last portion because if I run the script thru "bash -x" I get:
...
+ VERSION=$'3
.1
.0
.01
.002
'
+ echo $'3
.1
.0
.01
.002
'
.002

View 7 Replies View Related

Programming :: Converting A PHP Array Into An HTML Array?

Aug 9, 2009

I'm writing a PHP program. I've encountered a problem; in the following code I try to pass $_POST['delete'] which is an array as the value of a hidden input to some form, but it doesn't do so.there's something wrong with converting PHP array into HTML array. I'm sure that $_POST['delete'] is not null and is a real array.

echo '<input type="hidden" name="delete[]" value="'.$_POST['delete'].'" />';

View 4 Replies View Related

General :: Custom TCP Parameters For Multiple Interfaces - Change The Default Values

Feb 16, 2011

My question is about TCP parameters in Linux. By now, I want to change the default values of:

Initial Timeout
ACK Delay
Idle Connection Timeout

I have a Linux Box with kernel 2.6.x and 2 ethernet interfaces. I know TCP is a stack that doesn't have anything to do with ethernet devices. Said that, the question: is there a way to set custom values for each interface? For example, a server listening to connections in eth0 would use one value for Idle Connection Timeout and another server listening to connections in eth1 could use a different value for that parameter.

View 4 Replies View Related

Programming :: Filling 2D Array With 1D Array In C?

May 26, 2010

(I am using vector() and matrix() functions from "Numerical recipes in C".)There are 100 numbers to be stored in 2D array of 10 rows and 10 columns.100 numbers are stored in a 1D array.I get "segmentation fault" at the line indicated in the segment of my code below:

Code:

:
:
#define size 100
#define nl 1

[code]....

View 12 Replies View Related

Programming :: Bash Array Add Function Example Using Indirect Array Reference As Function Argument?

Jun 20, 2010

I looked on the net for such function or example and didin't find anything, thus after having made one i guess it would be legitimate to drop it to see what others thinks of it.

#!/bin/bash
addelementtoarray()
{
local arrayname=$1

[code]....

View 10 Replies View Related

Programming :: Else &amp; Return Values?

Oct 12, 2010

i am having two small issues with a function i have made.sorry if it is a mess, i am still learning bash.the first is calling the nonpersistssh function (second line) and assigning the return value to nonpersistdiag.the function returns 1, but nonpersistdiag seems to only contain 0. i am unsure on how to proceed.the second problem is the nested else clause on line 10. it is a syntactical error. how would i declare it correctly?

Code: function endsession(){
nonpersistdiag=$[nonpersistssh]# a function that returns an exit code
sudo /etc/init.d/ssh stop; sshdiag=$?

[code]....

View 6 Replies View Related

Debian :: Setting Up A RAID Array With Multiple Partitions

May 23, 2011

I need to set up a RAID 1 array on Squeeze. I have 3 partitions: sda1 is root, sda5 is home, and sda6 is swap. (sda2 is the extended partition containing home and swap. This was a clean installation, so I don't know what happened to sda3 and sda4...)

All the information that I've been able to find recommends doing something like this:

mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1

Do I need to type a separate command for each partition, or is there a better way to do it? Also, should I use the UUID instead of the dev names?

View 4 Replies View Related

Programming :: Modifying Hex Values From A Script?

Nov 11, 2010

I can use hexedit to manually edit one or two hex values in a binary file, but if I want to change many of the, this is impractical. Is there any tool that will take parameters like Code: someTool filename byteNumber replacementByte ?

View 3 Replies View Related

Programming :: Get Variable Values From Keyboard?

Jul 11, 2010

I have been reading the Wikibook on C Programming for quite some time and am up to the variable part. I did learn several new things, like that too many variables hog memory.

What I want to know is how to assign a variable to the keyboard (in the C/C++ family) as such that the user has to type it in.

View 2 Replies View Related

Programming :: Passing Values Through Pages?

May 23, 2010

I have the following snippet HTML code:

Quote:

<table id="profile">
<tr>...............</tr>
<tr>
<td width="40%">

[Code].....

How can pass values in args[0] and args[1] to Perl/CGI script?

View 2 Replies View Related

Programming :: Possible To Communicate Values Between Class?

Feb 24, 2009

I have a application in C++, and now I have two class. MyDialog is the class that main function launch. In MyDialog class there are four elements and when I click over theese elements, there is a MousePressEvent that launch other class, Touchpad class. So, in some moments, I have loaded two class. My question is, how can pass a value from Touchpad class to MyDialog class, when I close (destroy) Touchpad class. In a few words, is it possible to communicate values between class?

View 5 Replies View Related

Debian Hardware :: RAID As Multiple Disks - Configuring Array?

Dec 2, 2010

Alright, I have this issue on both SystemRescueCD and Debian Squeeze. I have an ASUS P5Q Turbo board that supports hardware RAID. If I configure an array and then start the Linux installer or boot the rescue CD, I get /dev/sda and /dev/sdb instead of an array. What gives? I need to start installing within the hour so I am desperate for an answer!

View 1 Replies View Related

CentOS 5 :: Installing 5.4 With Multiple Raid Levels On A 4 Disk Array?

Nov 17, 2009

Our server is a CybertronPC I2XV9080 Imperium Tower. It is equipped with a supermicro X7DVL-I Motherboard and Quad 750 GB SATA2 RAID edition hard drives in a raid 5 array. We tried to install Centos on the Raid5 array with Device-Mapper as the LVM. In the BIOS SATA Raid was enabled and the ICH RAID code base option was set to [Intel].

Intel Matrix Storage Manager Option ROM V5.6.4.1002 ESB2
RAID
ID Name Level Strip Size Status Bootable
0 Raid5 Raid 5 64KB 80GB Normal Yes
1 Raid_5 Raid 5 64kB 2000GB Normal Yes[code].....

Can I have multiple level raids across the same array or would that lead to problems as above? Is the root cause of my problem the fact that intel raid5 is not supported for Linux as based on the following link http:[url]....

View 3 Replies View Related

Debian Programming :: Returning Different Values For Same Code?

Sep 11, 2014

I am developing a script to automate some database setup, but I have an issue I cannot figure out. I prompt for some input with whiptail and select a default if nothing is entered. However, if you do not enter anything, it normally returns 0, but this time it is returning an empty value.

Code: Select all  # This one does work!

  # Set the source path
  TMPPATH=$(whiptail --backtitle "Linux Build Configuration"
    --title "Source-Code Path"
    --inputbox "Default: $SRCPATH" 0 60
    3>&2 2>&1 1>&3)

[Code] ....

So what is wrong with the second code?

View 1 Replies View Related







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