Programming :: Korn - Combine Select With An Array?
Jun 8, 2010Assume this array in Korn:
Code:
HOSTS[ home ]="163.164.165.166"
HOSTS[ work ]="122.123.124.125"
[code]....
Assume this array in Korn:
Code:
HOSTS[ home ]="163.164.165.166"
HOSTS[ work ]="122.123.124.125"
[code]....
I need to know how to assign a result from a select. I am clueless on the sytax. I am trying this in bash. Maybe I am not assigning the array right. It gives me the whole row in the echo instead of just field a. How do I get fieldA = a in the select. Note script was stripped for security on database info but the syntax is same.
Code:
#!/bin/sh
results="$(mysql --user ${DB_USER} -p${DB_PWD} ${DB_NAME} -Bse 'select a,b,c,d from tblMytable')"
for rows in "${results[@]}"
do
fieldA=${rows[0]};
echo ${fieldA};
done
I got my system up and running with the Grub installed on my primary hard drive. I have not installed 2 additional drives. I would like to combine the 2 additional drives into a RAID 1 array. I can only find tutorials on how to do this during initial install. I cannot find one that tell me how to do it after the install. Is there a way?
View 3 Replies View RelatedSomehow I'm not really managing this thing, which would d be a nice way to useariables.What I am doing is setting up compound variable in ksh. What I have is a "config" file, which has fields delimited by a semicolon
Code:
cat ${CONFIGFILE} | grep -v "^#" | grep -v "^$" | while read line
do
[code]...
I have scowered the internet for the answer to this one. I need a script to rename multiple files to the same exact name, run a program on the file then do the same for the next file. We have a unix backend system that is expecting to load the file with the filename of cards.in So I will have files named card.2009xxx, like i said i will have around 4 or five of those. I want the script to rename card.2009xxx to cards.in, run our unix program on cards.in which inturn changes the file name and once complete i want the script to rename the next cards.2009 to "cards.in"Until there are no more left in the directory and the unix program has processed all the files. All of this is occurring in the same directory. I have written some scripts but they fail by moving for example cards.200901 to cards.in then immediately moving cards.200902 to cards.in and that is not good because it is overwriting valuable data
View 10 Replies View RelatedI 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....
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?
Code...
how to combine a and b to c
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'].'" />';
I have a little test program consisting of a NASM source file and a C source file.How do I turn them into a single program?
Code:
section .data
msg db 'Hello, World!', 10
[code]....
My backup script generates 2 lengthy log file. They have the same name, but the date is appended. I want to select the oldest one, condense it with "head" and "tail" and then append the condensed version of the newer one. They seem to get tangled up.Code:
ls `find . -iname "bak-log_*"` -1t | tail -1
and
ls `find . -iname "bak-log_*"` -rt | tail -1
[code]...
(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]....
I would like to combine two arrays and delete duplicates that might occur. I tried to solve it like this:
Code:
combined=( "${results1[@]}" "${results2[@]}" )
printf "${combined[@]}" | sort -n | uniq
Example:
result1 (4 elements):
[Code]....
In my code printf seems to have a problem with elements that have the same letters but a space inbetween. For instance "new foo", "newfoo" are the same for printf
We have a program that catalogs to 40 different mount points. The program is fine as long as thier is free space on at least one of the 40 mount points. My boss wants me to come up with a script that will email us daily to know how much overall free space is left. I know I can do a df but I don't know how to combine the 40 mount points into a single disk used/disk free report.
The 40 mount points are /dev/mapper/areaxx, xx being 01 to 40.
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]....
I have two files, uploads.txt and downloads.txt. I would like to combine the columns of these files based on the ip address. How can I best do this?
Uploads.txt Code: 192.168.0.147 1565369
192.168.0.13 1664855
192.168.0.6 1332868 Downloads.txt Code: 192.168.0.147 9838820
[code]...
I have currently had the need to go back to basic socket programming, and implemented a simple udp packet sender. But I realized I needed to be able to select which network interface to send the packets from.
The reason is so that one of the interfaces has vlan tagging, and I need my UDP packets to be accordingly vlan tagged. For example, one of the interfaces is eth1.200.
I wonder why arrays in the C programming language are pointers to the first element of the array, not the first element of the array itself?
View 14 Replies View RelatedIs there any Linux utility to combine two or more binary files into a single binary file ?
View 7 Replies View RelatedIve been playing around with Linux a little bit and have started to look into different shell types. I know BASH is the most basic, or that is in most distro. but is there any disadvantages of using a Korn shell instead?
View 7 Replies View RelatedI am new and start learning how to write korn shell, can you someone please translate the below command to common English? code...
View 1 Replies View RelatedI have a fallowing CGI script, which does nothing more than prints out the values user inserted:
Code:
If I insert Martin to the name box and 192.168.1.1 to the IP box I get fallowing output:
Quote:
Name is Martin
IP address is 192.168.1.1
As you can see, script above works fine(I host this script in Apache server and use Firefox as a web-client). Now I made a fallowing bash script:
Code:
Which is started like this: ./script.sh Martin 192.168.1.1. Output is user name plus port numbers and descriptions. This bash script works fine as well
How can I combine those two scripts? I would like to insert name and IP to according boxes in Firefox and after clicking Generate button, user name plus list of port numbers and descriptions will appear in Firefox window instead of terminal emulator window
How to link/combine those two scripts to work together as one?
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..
Im wondering how to create a menu in c like bash's select. I imagine there is already something out but I don't know what it would be. Im a c newb but been scripting for a long time now and trying to pick up a little c.this would be what I am looking to display:
Code:
1) option 1
2) option 2
3) option 3
Make a selection:obviously 1,2,3 would be the only valid selection and anything else would say invalid or something like that.
Trying to export a Mysql query to a .csv file the query draws from multiple tables, e.g. sales, purchase and currency
Code:
What i'm trying to do is to export both the sales and purchase to a single line where both the currency for the sales and the purchase is specified.
Basically like this:
Code:
Problem here is that i'm stating currency.value twice in the same select and don't know how to define which currency.value applies to sales and which to purchase.
I'm trying to make a very small script with greasemonkey to do some automatic things when a page loads. The first thing I need to do is to click on a link. I've done that. Then I need to select the 3rd element of a drop down list that appears a few moments (depending on the connection) after the link is pressed, without reloading the page (ajax or something like that). This I can't get to work, The select has no id or class, but I can get its xpath value. There is only one select on the page. I've tried both setTimeOut and the DOMNodeInserted event with no effect.
Code:
// ==UserScript==
// @name test
// @namespace "www.google.com"
// @include www.mywebpage.com
// ==/UserScript==
[Code]....
I'm writing a PHP script, and I need a top 10 result from a mysql query.I've tryed like this:select IP,sum(download) from traf group by IP order by ASC limit 0,10and my sql returnsmysql> select IP,sum(download) from traf group by IP order by ASC limit 0, 10;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC limit 0, 10' at line 1As I red through Google this is not quite supported by mysql, so is there another way to do this?
View 5 Replies View RelatedI want to select the branch based on the INPUT. Here is the program segment which uses the case statement.
case $INPUT in
1)branch="Computer Science";;
2)branch ="Electrical";;
3)branch = "Mechanical";;
4)branch= "Aerospace";;
esac
When I run this script, I am getting an error, Electrical command not found?
I am trying to update I get this errorFailed to fetch [URL]404 Not FoundSome index files failed to download, they have been ignored, or old ones used instead.
View 8 Replies View RelatedI'm facing a strange problem with our code. What the program does is to wait on a select() after a non-blocking connect. And I expect the select wake up with write_set after the ESTAB. And I expect select wakeup with both rd_set and wr_set if I recv a RST back for our SYN or any similar errors. But in one of the cases I'm seeing select is waking up with only rd_set in a non-connected sockeet, which is causing a lot of problems for me.
The code is organized such that the socket close() happens only in wr_set processing. Because of that with the above problem I'm going in to a strange scenario. After the event I call select() again and wait for another socket event. But with this issue, my select is waking up there after everytime as soon as I call select(). That too only with rd_set. So it keeps on going with select() sleeping 0 secs. Thus the program is hung and eating lot of CPU cycles also.
The trigger for all these problems seems to be some event which causes the waking up of select() with rd_set only. I tried many ways to find out what is happening with this. Couldn't find anything interesting yet.