Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Testing for non-zero length string Post 302580517 by ryran on Thursday 8th of December 2011 06:14:42 PM
Old 12-08-2011
Since you're using bash, you could avoid this problem in the first place by using the shell keywords [[ and ]] instead. All around better. See here for more info: wiki.bash-hackers.org/syntax/ccmd/conditional_expression
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Testing the last character in a string

Hi In the shell scripted I'm trying to write! I would like to test the last character in a string. The string is a path/directory and I want to see if the last character is a '/'. The string (path/directory) is inputted by a user. If the '/' character isn't present then I want to be able to... (11 Replies)
Discussion started by: dbrundrett
11 Replies

2. UNIX for Dummies Questions & Answers

length of the string

Hi all, pls help me in finding the length of the given string, do we need to write a code seperately or is there any command?? pls help. (3 Replies)
Discussion started by: vasikaran
3 Replies

3. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies

4. Shell Programming and Scripting

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies

5. UNIX for Dummies Questions & Answers

length of string

Hi lets say i have a variable output="string" how can you find the length of the string contained in this variable? i guess "wc" cannot be used. its only for files. (8 Replies)
Discussion started by: silas.john
8 Replies

6. Shell Programming and Scripting

testing length

I've never tested file length with shell before and I'm having problems. What I'm doing is testing $filename and $filename.bak to see if there is a difference. so I use 'diff' for that and send it to an output file 'dif.txt'. Now I wanna see if the length of 'dif.txt' is zero or not. that's where... (1 Reply)
Discussion started by: astonmartin
1 Replies

7. Shell Programming and Scripting

need help testing for length of variable

Hello, I'm new to shell scripting and need a little help please. I'm working on a script that asks the user to input a name that can be 1 to 12 alphanumeric characters and can have dots(.) dashes(-) and spaces. I want to test that the answer is valid and if not make the user try again. I have no... (4 Replies)
Discussion started by: wlewis
4 Replies

8. Programming

regarding string length

Helo, I have character array of sixe 128 char filename now I have one problem that when I enter filename as nothing I got value as " " ",`\0` " . when I find this string length ( " ",`\0`) as 1(one). actually I want to make this length as zero. so what should I do (10 Replies)
Discussion started by: amitpansuria
10 Replies

9. UNIX for Dummies Questions & Answers

Read a string with leading spaces and find the length of the string

HI In my script, i am reading the input from the user and want to find the length of the string. The input may contain leading spaces. Right now, when leading spaces are there, they are not counted. Kindly help me My script is like below. I am using the ksh. #!/usr/bin/ksh echo... (2 Replies)
Discussion started by: dayamatrix
2 Replies

10. Shell Programming and Scripting

Testing the length of a string

Hello, Unix-Forums! Is there a command that can check how long a user-entered string is? Please don't give me a code, just the name of the command (playing around yourself is much more fun than just pasting code) edit: I'm sorry, first hit of the forum search gave me the answer. (1 Reply)
Discussion started by: intelinside
1 Replies
Ns_UrlSpecific(3aolserver)				   AOLserver Library Procedures 				Ns_UrlSpecific(3aolserver)

__________________________________________________________________________________________________________________________________________________

NAME
Ns_UrlSpecificAlloc, Ns_UrlSpecificDestroy, Ns_UrlSpecificGet, Ns_UrlSpecificGetExact, Ns_UrlSpecificGetFast, Ns_UrlSpecificSet - Store and retrieve URL-specific data SYNOPSIS
#include "ns.h" int Ns_UrlSpecificAlloc(void) void * Ns_UrlSpecificDestroy(char *server, char *method, char *url, int id, int flags) void * Ns_UrlSpecificGet(char *server, char *method, char *url, int id) void * Ns_UrlSpecificGetExact(char *server, char *method, char *url, int id, int flags) void * Ns_UrlSpecificGetFast(char *server, char *method, char *url, int id) void Ns_UrlSpecificSet(char *server, char *method, char *url, int id, void *data, int flags, void (*deletefunc) (void *)) _________________________________________________________________ DESCRIPTION
These functions allow you to store URL-specific data in memory for later retrieval. They are used when registering procedures for example. Ns_UrlSpecificAlloc() Return a unique ID used to identify a unique virtual URL-space that is then used with the Ns_UrlSpecific storage functions. You should only call this function at server startup, and not after. Here is an example: static int myId; void Init(void) { /* Allocate the id once at startup. */ myId = Ns_UrlSpecificAlloc(); } void Store(char *server, char *method, char *url, char *data) { Ns_UrlSpecificSet(server, method, url, myId, data, 0, NULL); } char * Fetch(char *server, char *method, char *url) { char *data; data = Ns_UrlSpecificGet(server, method, url, myId); return (char *) data; } Ns_UrlSpecificDestroy(server, method, url, id, flags) The Ns_UrlSpecificDestroy function deletes URL-specific data previously stored with Ns_UrlSpecificSet with the same method/URL com- bination and the same inheritance setting. An id of -1 matches all ids. For example, Ns_UrlSpecificDestroy("myserver", "GET", "/", -1, NS_OP_RECURSE) removes all data for the method GET for server "myserver". The flags argument can be: NS_OP_NODELETE - If set, the deletefunc specified in Ns_UrlSpeciciSet is run. NS_OP_RECURSE - If set, then data for all URLs more specific than the passed-in URL are also destroyed. NS_OP_NOINHERIT - If set, data that was stored with this flag in Ns_UrlSpecificSet will be deleted. If not set, the data stored without this flag will be deleted. Ns_UrlSpecificGet(server, method, url, id) The Ns_UrlSpecificGet function retrieves the best match that it can find for in the URL subspace identified by id that the passed-in URL matches. For instance, suppose you had previously registered a handle/method/url/id combination of {myserver, GET, /, 1} and {myserver, GET, /inventory, 1}. The following call would match the data registered at {myserver, GET, /inventory, 1}: Ns_UrlSpecificGet("myserver", "GET", "/inventory/RJ45", 1) Ns_UrlSpecificGetExact(server, method, url, id, flags) Retrieves stored data for the exact method/URL/id combination specified that was stored with the same inheritance setting. If the flags argument is set to NS_OP_NOINHERIT, the data stored with NS_OP_NOINHERIT will be retrieved. If the flags argument is set to 0, the data stored without NS_OP_NOINHERIT will be retrieved. Ns_UrlSpecificGetFast(server, method, url, id) Same as Ns_UrlSpecificGet but does not support wildcards, making it much faster. Ns_UrlSpecificSet(server, method, url, id, data, flags, deletefunc) The Ns_UrlSpecificSet function stores data in memory, allowing subsequent retrieval using handle, method, url, id, and inheritance flag. The flags argument can be NS_OP_NOINHERIT or NS_OP_NODELETE. You can store two sets of data based on the same handle, method, url, and id combination-- one set with inheritance on and one set with inheritance off. If the NS_OP_NOINHERIT flag is set, the data is stored based on the exact URL. If NS_OP_NOINHERIT is omitted, the data is stored based on the specified URL and any URL below it. In this case, Ns_UrlSpecificGetExact will match to the closest URL when retrieving the data. The deletefunc argument is called with data as an argument when this handle/url/method/id combination is re-registered or deleted, or when this server shuts down. unless NS_OP_NODELETE is set. Normally, calling Ns_UrlSpecificSet on a handle/url/method/id combination which already has an operation registered for it causes the previous operation's delete procedure to be called. You can override this behavior by adding the NS_OP_NODELETE flag. SEE ALSO
nsd(1), info(n) KEYWORDS
AOLserver 4.0 Ns_UrlSpecific(3aolserver)
All times are GMT -4. The time now is 08:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy