03-02-2020
@RudiC, much appreciated.
Your comment on this not being the best approach is not surprising ;-)... I continue to try and improve my efforts but due to my skill level, usually start with functionality. I will investigate your suggestion of associative arrays.
Any high level example of how to better do what I'm trying with associative arrays?
Thanks again..
HB
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
We have a script that runs in ksh on HP-UX 11.11. It takes three arguments. The last argument can be a filename or wildcard character. For example:
script -s hello -t goodbye '*.d*'
In a case such as this, I would wrap single quotes around the final argument because I dont want the shell to... (4 Replies)
Discussion started by: dangral
4 Replies
2. Shell Programming and Scripting
#!/usr/bin/bash
if
then
echo "Not valid arguments entered. Just username should be entered."
else
USER_NAME=$1
FILE_NAME=$USER_NAME.info
UNN=STUDIN\\\\$1
echo $UNN
last STUDIN\\\\$1
last UNN
If I type `last STUDIN\\eip060` it works but if I try to expand it with variable it is... (5 Replies)
Discussion started by: Zammy_bg
5 Replies
3. Shell Programming and Scripting
Hello -
I have a bash script which does some logging, and I'd like to include the line number of the echo statement that pipes into $LOGGER:
MYPID=$$
MYNAME=`basename $0`
LOGGER="/usr/bin/logger -t $MYNAME($LINENO) -p daemon.error"
...
echo 'this is an entry into the log file' | $LOGGER
... (3 Replies)
Discussion started by: scandora
3 Replies
4. UNIX for Dummies Questions & Answers
I'm in the habit of using the following type of loop structure:
for num in `seq $1 $2`
do
command
doneWhile `seq $1 $2` is not exactly a huge resource hog, I would like to learn a better way. It seems that brace expansion is a good way to go:
for num in {3..10}The problem, though, is... (2 Replies)
Discussion started by: treesloth
2 Replies
5. Shell Programming and Scripting
i write a batch file , here is the content.
dirname='date +%Y-%m-%d'
mkdir dirname
but it doen's work, it just create a folder named date and +%Y-%m-%d.
i have tried run the command seperately in the bash prompt. after the first
sentence executed , i use $dirname to watch the value of... (4 Replies)
Discussion started by: premotheus
4 Replies
6. Shell Programming and Scripting
The objective of the code below is to create sed script to be later executed. However, it bonks because $ARCHIVENAME expands to a directory specification so the forward slashes cause problems. I can think of a few solutions that would involve redesigning the process, but I'm hoping there might be... (4 Replies)
Discussion started by: tiggyboo
4 Replies
7. Shell Programming and Scripting
Hi forum,
in my bash script I've many lines executing commands with redirection to log files.
...
xyz_cmd 2>&1 > $BASENAME.$LINENO
The trailing part of these lines doesn't look nice and I like to put it into a variable.
The (not working) idea is something like that
... (3 Replies)
Discussion started by: wolfi089
3 Replies
8. UNIX for Dummies Questions & Answers
So, I was bored on the train today, and was thinking of ways to loop through elements of an array. I came up with the following simple script, but it doesn't work as brace expansion doesn't seem to work with variables. Is there something I'm missing, or does the shell just not work like this?
... (4 Replies)
Discussion started by: DeCoTwc
4 Replies
9. Shell Programming and Scripting
Hello,
I have one variable coming from one file:
abc=$xyz/filename.txt where $xyz is defined in .profile file as say, /usr/dev/src
i am passing abc variable to one perl script as input parameter.
perl 123.pl -s $abc
But inside the perl script execution, the variable $abc is just... (1 Reply)
Discussion started by: vikas_trl
1 Replies
10. Shell Programming and Scripting
Hello.
The file /etc/fstab contains
UUID=957c3295-9944-1593-82e2-2b90dede4312 / ext4 noatime,discard,acl,user_xattr 1 1
I fill a variable
SOME_LINE=$( cat /etc/fstab | grep \/\..*ext4 | grep noatime,discard )echo $SOME_LINE... (3 Replies)
Discussion started by: jcdole
3 Replies
LEARN ABOUT PHP
ingres_fetch_array
INGRES_FETCH_ARRAY(3) 1 INGRES_FETCH_ARRAY(3)
ingres_fetch_array - Fetch a row of result into an array
SYNOPSIS
array ingres_fetch_array (resource $result, [int $result_type])
DESCRIPTION
This function is an extended version of ingres_fetch_row(3). In addition to storing the data in the numeric indices of the result array,
it also stores the data in associative indices, using the field names as keys.
If two or more columns of the result have the same field names, the last column will take precedence. To access the another column or col-
umns of the same name, you must use the numeric index of the column or make an alias for the column. For example:
<?php
$result = ingres_query($link, "select ap_place as city, ap_ccode as country from airport where ap_iatacode = 'VLL'");
$result = ingres_fetch_array($result);
$foo = $result["city"];
$bar = $result["country"];
?>
With regard to speed, the function is identical to ingres_fetch_object(3), and almost as quick as ingres_fetch_row(3) (the difference is
insignificant).
By default, arrays created by ingres_fetch_array(3) start from position 1 and not 0 as with other DBMS extensions. The starting position
can be adjusted to 0 using the configuration parameter ingres.array_index_start.
Note
Related Configurations
See also the ingres.array_index_start, ingres.fetch_buffer_size and ingres.utf8 directives in Runtime Configuration.
PARAMETERS
o $result
- The query result identifier
o $result_type
- The result type. This $result_type can be INGRES_NUM for enumerated array, INGRES_ASSOC for associative array, or INGRES_BOTH
(default).
RETURN VALUES
Returns an array that corresponds to the fetched row, or FALSE if there are no more rows
EXAMPLES
Example #1
Fetch a row of result into an array
<?php
$link = ingres_connect($database, $user, $password);
$result = ingres_query($link,"select * from table");
while ($row = ingres_fetch_array($result)) {
echo $row["user_id"]; // using associative array
echo $row["fullname"];
echo $row[1]; // using enumerated array
echo $row[2];
}
?>
SEE ALSO
ingres_query(3), ingres_num_fields(3), ingres_field_name(3), ingres_fetch_assoc(3), ingres_fetch_object(3), ingres_fetch_row(3).
PHP Documentation Group INGRES_FETCH_ARRAY(3)