Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Testing for non-zero length string Post 302580084 by longjon on Wednesday 7th of December 2011 12:00:53 PM
Old 12-07-2011
Testing for non-zero length string

Hello, can someone please explain to me why this happens:

Code:
myserver#echo "$nothing"

myserver#if [ -z ${nothing} ]; then echo "nothing is a zero length string"; fi
nothing is a zero length string
myserver#if [ -n ${nothing} ]; then echo "nothing is also a non-zero length string, apparently"; fi
nothing is also a non-zero length string, apparently

Surely an undefined variable cannot be both zero-length and non-zero-length at the same time? I always have problems with the -n test flag - does it actually work? Smilie

I am using bash shell on a Solaris 9 server.

TIA,

jon
 

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
SMBTORTURE(1)							    Test Suite							     SMBTORTURE(1)

NAME
smbtorture - Run a series of tests against a SMB server SYNOPSIS
smbtorture {//server/share} [-d debuglevel] [-U user%pass] [-k] [-N numprocs] [-n netbios_name] [-W workgroup] [-o num_operations] [-e num files(entries)] [-O socket_options] [-m maximum_protocol] [-L] [-c CLIENT.TXT] [-t timelimit] [-C filename] [-A] [-p port] [-s seed] [-f max_failures] [-X] {BINDING-STRING|UNC} {TEST1} [TEST2] [...] DESCRIPTION
smbtorture is a testsuite that runs several tests against a SMB server. All tests are known to succeed against a Windows 2003 server (?). Smbtorture's primary goal is finding differences in implementations of the SMB protocol and testing SMB servers. Any number of tests can be specified on the command-line. If no tests are specified, all tests are run. If no arguments are specified at all, all available options and tests are listed. Binding string format The binding string format is: TRANSPORT:host[flags] Where TRANSPORT is either ncacn_np for SMB, ncacn_ip_tcp for RPC/TCP or ncalrpc for local connections. 'host' is an IP or hostname or netbios name. If the binding string identifies the server side of an endpoint, 'host' may be an empty string. 'flags' can include a SMB pipe name if using the ncacn_np transport or a TCP port number if using the ncacn_ip_tcp transport, otherwise they will be auto-determined. other recognised flags are: sign enable ntlmssp signing seal enable ntlmssp sealing connect enable rpc connect level auth (auth, but no sign or seal) validate enable the NDR validator print enable debugging of the packets bigendian use bigendian RPC padcheck check reply data for non-zero pad bytes For example, these all connect to the samr pipe: o ncacn_np:myserver o ncacn_np:myserver[samr] o ncacn_np:myserver[\pipe\samr] o ncacn_np:myserver[/pipe/samr] o ncacn_np:myserver[samr,sign,print] o ncacn_np:myserver[\pipe\samr,sign,seal,bigendian] o ncacn_np:myserver[/pipe/samr,seal,validate] o ncacn_np: o ncacn_np:[/pipe/samr] o ncacn_ip_tcp:myserver o ncacn_ip_tcp:myserver[1024] o ncacn_ip_tcp:myserver[1024,sign,seal] o ncalrpc: UNC Format The UNC format is: //server/share OPTIONS
-d debuglevel Use the specified Samba debug level. A higher debug level means more output. -U user%pass Use the specified username/password combination when logging in to a remote server. -k Use kerberos when authenticating. -W workgroup Use specified name as our workgroup name. -n netbios_name Use specified name as our NetBIOS name. -O socket_options Use specified socket options, equivalent of the smb.conf option "socket options". See the smb.conf(5) manpage for details. -m max_protocol Specify the maximum SMB dialect that should be used. Possible values are: CORE, COREPLUS, LANMAN1, LANMAN2, NT1 -s seed Initialize the randomizer using seed as seed. -L Use oplocks. -X Enable dangerous tests. Use with care! This might crash your server... -t timelimit Specify the NBENCH time limit in seconds. Defaults to 600. -p ports Specify ports to connect to. -c file Read NBENCH commands from file instead of from CLIENT.TXT. -A Show not just OK or FAILED but more detailed output. Used only by DENY test at the moment. -C filename Load a list of UNC names from the specified filename. Smbtorture instances will connect to a random host from this list. -N numprocs Specify number of smbtorture processes to launch. -o num_operations Number of times some operations should be tried before assuming they're output is consistent (default:100). -e num_files Number of entries to use in certain tests (such as creating X files) (default: 1000). -f max_failures Number of failures before aborting a test (default: 1). VERSION
This man page is correct for version 4.0 of the Samba suite. SEE ALSO
Samba AUTHOR
This utility is part of the Samba[1] suite, which is developed by the global Samba Team[2]. smbtorture was written by Andrew Tridgell. This manpage was written by Jelmer Vernooij. NOTES
1. Samba http://www.samba.org/ 2. Samba Team http://www.samba.org/samba/team/ Samba 4.0 06/17/2014 SMBTORTURE(1)
All times are GMT -4. The time now is 03:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy