I'm using the following command to test for certain characters in a script
echo "${1}" | grep '\$'
if (( ${?} == 0 ))
then
testing this script on the command line I have
ksh -x script1.sh "xxxx$xxxx"
this works fine but when I want to use
ksh -x script1.sh "xxxx $xxx"
the... (1 Reply)
Hi,
I have two files with the following content:
gmrd.txt
235649;03;2563;598
291802;00;2563;598
314634;00;235649;598
235649;03;2563;598
393692;00;2563;598
411805;00;2563;598
411805;00;2563;598
235649;03;2563;598
414037;00;2563;598
575200;00;2563;598
70710;00;2563;598... (11 Replies)
well i have this code here..and it works fine in kornshell..
#!/bin/ksh
home=c:/..../
input=$1
sed '1,3d' $input > $1.out
line=""
cat $1.out | while read a
do
line="$line $a"
done
echo $line > $1
rm $1.out
however...now i want it just in normal sh mode..how to convert this?... (21 Replies)
I'm needing help with assigning variables inside a while loop of ksh script.
I have an input text file and ksh script below and I'm trying to create a script which will read the input file line by line, assign first and second word to variables and process the variables according to the contents. ... (4 Replies)
I am wracking my brains over this. I am trying to use a Korn Shell script to execute an Oracle PL/SQL procedure, using the Oracle command line interface (sqlplus). The script starts sqlplus in a coprocess, and the two processes communicate using a two-way pipe. The bgnice option is off, so both... (8 Replies)
Hi all,
I am trying to tweak my ksh , i am running V: Version M-11/16/88i
I have my Backspace and up/down arrows working using the following code in my ~/.profile file.
set -o emacs
alias __A=$(print '\020' )
alias __B=$(print '\016' )
alias __C=$(print '\006' )
alias __D=$(print... (4 Replies)
I am modifying a Korn shell script in using the Exceed (Solaris 10 environment). My task is to read in a .txt file with dates arranged like this (01-Sep-2006). I am to read each line and take the dates, compare them to a benchmark date and depending on if it is older than the date or the date and... (6 Replies)
Ho do I find out the verion of the Kron shell on my client`s system ?
There is no one to ask. They are not knowledged enough (hard to believe but yes).
Also, on that AIX 4.2, I am trying to figure out how to do a grep using a search patter like below but does not seam to work. The '*' do... (11 Replies)
Hi to everybody!
I want to write a simple script in ksh that decrypts and encrypts using the DES algorithm.
There is no builtin function in UNIX : i have found only a function in openssl but i don't understand how to use it.
The script must accept in input the plaitext and the DESKEY in... (2 Replies)
how do you show each filename in a giving directory and delete the specific file in korn script
i was thinking using ls rm ? but i cant make it work (0 Replies)
Discussion started by: babuda0059
0 Replies
LEARN ABOUT DEBIAN
ggstrlcat
ggstrlcpy(3) GGI ggstrlcpy(3)NAME
ggstrlcpy, ggstrlcat - size-bounded string copying and concatenation
SYNOPSIS
#include <ggi/gg.h>
size_t ggstrlcpy(char *dst, const char *src, size_t siz);
size_t ggstrlcat(char *dst, const char *src, size_t siz);
DESCRIPTION
The ggstrlcpy and ggstrlcat 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, ggstrlcpy and ggstrlcat 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 ggstrlcat, as long as
there is at least one byte free in dst). Note that you should include a byte for the NUL in size. Also note that ggstrlcpy and ggstrlcat
only operate on true C strings. This means that for ggstrlcpy src must be NUL-terminated and for ggstrlcat both src and dst must be NUL-
terminated.
The ggstrlcpy function copies up to siz - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result.
The ggstrlcat function appends the NUL-terminated string src to the end of dst. It will append at most siz - strlen(dst) - 1 bytes, NUL-
terminating the result.
RETURN VALUES
The ggstrlcpy and ggstrlcat functions return the total length of the string they tried to create. For ggstrlcpy that means the length of
src. For ggstrlcat 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 ggstrlcat 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 ggstrlcat 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)ggstrlcpy(buf, s, sizeof(buf));
(void)ggstrlcat(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 (ggstrlcpy(pname, dir, sizeof(pname)) >= sizeof(pname))
goto toolong;
if (ggstrlcat(pname, file, sizeof(pname)) >= sizeof(pname))
goto toolong;
Since we know how many characters we copied the first time, we can speed things up a bit by using a copy instead of an append:
char *dir, *file, pname[MAXPATHLEN];
size_t n;
...
n = ggstrlcpy(pname, dir, sizeof(pname));
if (n >= sizeof(pname))
goto toolong;
if (ggstrlcpy(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 ggstrlcpy and ggstrlcat.
SEE ALSO snprintf(3)strncat(3)strncpy(3)HISTORY
strlcpy and strlcat first appeared in OpenBSD 2.4, then in NetBSD 1.4.3 and FreeBSD 3.3.0. ggstrlcpy and ggstrlcat has been added to libgg
for portability.
libgg-1.0.x 2005-08-26 ggstrlcpy(3)