Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Adding to an array in an external file, and adding elements to it. Post 303032502 by Corona688 on Tuesday 19th of March 2019 11:42:01 AM
Old 03-19-2019
Why would it telnet to anything? I see that nowhere in your code.

This may be helpful:
Code:
arraylength=sizeof(testarray)/sizeof(char *); // Placeholder, only works with predefined arrays

 

10 More Discussions You Might Find Interesting

1. Solaris

adding existing disks to a 3510 array

I would like to extend a logical drive on our 3510. I have four unallocated disks which I would like to use for this purpose. The 3510 supports a Sun Cluster but for now all I wish to see is a "new" disk when I run format. I am a little familiar with the telnet/ssh session on the 3510 but am... (2 Replies)
Discussion started by: malcqv
2 Replies

2. Shell Programming and Scripting

Search array elements as file for a matching string

I would like to find a list of files in a directory less than 2 days old and put them into an array variable. And then search for each file in the array for a matching string say "Return-code= 0". If it matches, then display the array element with a message as "OK". Your help will be greatly... (1 Reply)
Discussion started by: mkbaral
1 Replies

3. Shell Programming and Scripting

Adding array element in KSH

All, I would like to add the first 10 elements of an array. Here is how I am doing it now (only included first few add ops): #!/usr/bin/ksh ###Grab the array values out of a file### TOTAL=`awk '/time/' /tmp/file.out | awk '{print $4}'` set -A times $TOTAL SUM=$((${times} + times... (3 Replies)
Discussion started by: Shoeless_Mike
3 Replies

4. Solaris

Adding external disk array to a live server

Hi all Ive got a v440 with an external T3 RAID in a dual bus configuration. I need to add an additional JBOD extension to the disk array via two VDCH cables. Now, can I do this as the server is live ? Can I just plug the two cables in, switch on the additional extension ? Will this cause... (1 Reply)
Discussion started by: sbk1972
1 Replies

5. Shell Programming and Scripting

Problem adding into an array field!!!

Hi, Kindly assist by analyzing the code below and suggest changes to achieve the required output. The input file: 01-010241800000 35000 MV010 02/03/09 0306 03060226 03 02-004103300000 470000 MV010 02/03/09 0301 03010276 03 The objective is to convert field No4. from dd/mm/yy to yyyymmdd... (5 Replies)
Discussion started by: talk2pawee
5 Replies

6. Shell Programming and Scripting

Adding new lines to a file + adding suffix to a pattern

I need some help with adding lines to file and substitute a pattern. Ok I have a file: #cat names.txt name: John Doe stationed: 1 name: Michael Sweets stationed: 41 . . . And would like to change it to: name: John Doe employed permanently stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies

7. Shell Programming and Scripting

Adding results of a find to an array

I'm trying to add the paths of all the xml files in certain directories to an array. I want to use the array later in my code. Anyway, for some reason this isn't working. Any help would be appreciated. Path_Counter=0 for result in "find * -name '*.xml'"; do XmlPath="$result" echo... (2 Replies)
Discussion started by: Fly_Moe
2 Replies

8. Shell Programming and Scripting

Adding an element to a bash array with a variable

Hello, I have a simple task and I am having some trouble with the syntax. I have a variable with an assigned value, CMD_STRING='-L 22 -s 0 -r -O -A i -N 100 -n' I would like to add that variable to an array. As far as I have been able to look up, the syntax should be something like, ... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

9. Solaris

Solaris - Sendmail - Adding .com.gr in external senders e-mails

Hello Everybody ! I'm Harry from Athens Greece and i have a problem with my Sendmail 8.13.3 installed on Solaris SunOS ultra 5.10. The problem is that when someone sends to us an e-mail and his e-mail address is like : xxxx@xxxx.com, our e-mail server adds up in the senders address a .com.gr... (2 Replies)
Discussion started by: Mcasim
2 Replies

10. Shell Programming and Scripting

Adding Two Array in shell script

Hi Experts, I've got this problem where I need to add two array in shell script such that that is an element is greater than 9 then it get further split into individual digit, something like below : Input :- array1=(2 6 8 9 10 12) array2=(5 4 6 8 12 14) Output :- array3=(7 1 0 1 4 1 7 2 2... (8 Replies)
Discussion started by: mukulverma2408
8 Replies
STRLCPY(3)						   BSD Library Functions Manual 						STRLCPY(3)

NAME
strlcpy, strlcat -- size-bounded string copying and concatenation LIBRARY
Utility functions from BSD systems (libbsd, -lbsd) SYNOPSIS
#include <bsd/string.h> size_t strlcpy(char *dst, const char *src, size_t size); size_t strlcat(char *dst, const char *src, size_t size); DESCRIPTION
The strlcpy() and strlcat() functions copy and concatenate strings respectively. They are designed to be safer, more consistent, and less error prone replacements for strncpy(3) and strncat(3). Unlike those functions, strlcpy() and strlcat() take the full size of the buffer (not just the length) and guarantee to NUL-terminate the result (as long as size is larger than 0 or, in the case of strlcat(), as long as there is at least one byte free in dst). Note that a byte for the NUL should be included in size. Also note that strlcpy() and strlcat() only operate on true ``C'' strings. This means that for strlcpy() src must be NUL-terminated and for strlcat() both src and dst must be NUL- terminated. The strlcpy() function copies up to size - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result. The strlcat() function appends the NUL-terminated string src to the end of dst. It will append at most size - strlen(dst) - 1 bytes, NUL- terminating the result. RETURN VALUES
The strlcpy() and strlcat() functions return the total length of the string they tried to create. For strlcpy() that means the length of src. For strlcat() that means the initial length of dst plus the length of src. While this may seem somewhat confusing, it was done to make truncation detection simple. Note, however, that if strlcat() traverses size characters without finding a NUL, the length of the string is considered to be size and the destination string will not be NUL-terminated (since there was no space for the NUL). This keeps strlcat() from running off the end of a string. In practice this should not happen (as it means that either size is incorrect or that dst is not a proper ``C'' string). The check exists to prevent potential security problems in incorrect code. EXAMPLES
The following code fragment illustrates the simple case: char *s, *p, buf[BUFSIZ]; ... (void)strlcpy(buf, s, sizeof(buf)); (void)strlcat(buf, p, sizeof(buf)); To detect truncation, perhaps while building a pathname, something like the following might be used: char *dir, *file, pname[MAXPATHLEN]; ... if (strlcpy(pname, dir, sizeof(pname)) >= sizeof(pname)) goto toolong; if (strlcat(pname, file, sizeof(pname)) >= sizeof(pname)) goto toolong; Since it is known how many characters were copied the first time, things can be sped up a bit by using a copy instead of an append: char *dir, *file, pname[MAXPATHLEN]; size_t n; ... n = strlcpy(pname, dir, sizeof(pname)); if (n >= sizeof(pname)) goto toolong; if (strlcpy(pname + n, file, sizeof(pname) - n) >= sizeof(pname) - n) goto toolong; However, one may question the validity of such optimizations, as they defeat the whole purpose of strlcpy() and strlcat(). As a matter of fact, the first version of this manual page got it wrong. SEE ALSO
snprintf(3), strncat(3), strncpy(3) HISTORY
The strlcpy() and strlcat() functions first appeared in OpenBSD 2.4, and made their appearance in FreeBSD 3.3. BSD
May 31, 2007 BSD
All times are GMT -4. The time now is 06:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy