Sponsored Content
Top Forums Shell Programming and Scripting Need a script to check if an argument is valid shell variable Post 302888041 by pingiliarjun on Wednesday 12th of February 2014 11:07:33 AM
Old 02-12-2014
This is what I have written but I am not sure if it is correct as I am new to UNIX
Code:
 
#!/bin/sh
FirstChar = cut -c1 $1
if [FirstChar -eq A-z] || [FirstChar -eq a-z]|| [FirstChar -eq '%']
then
    Echo "yes"
else
    Echo "no"
fi

Let me know if it is correct.

Thanks

Last edited by vbe; 02-12-2014 at 12:08 PM.. Reason: code tags...
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking the valid paths in the shell script

Hi i am using a shell script for renaming the files and placing in the remote location(FTP) my code is: cd $1 day=$(date +%d) for i in `ls -1 BBW*` do last=`tail -1 $i` pat=`expr "$last" : '.*(\(.*\)).*'` pat=`echo $pat | sed 's/ /_/'` pat=$pat$day mv $i $pat rm -f $day done... (3 Replies)
Discussion started by: srivsn
3 Replies

2. Shell Programming and Scripting

how to assign script argument to a variable

I have a script file. test.sh I am running it by command sh test.sh 10102004 where 10102004 is the script argument. I wan to assign this 10102004 to a variable. How can i do this? I tried &1 and awks ARGV its not working :( (2 Replies)
Discussion started by: rohankit
2 Replies

3. Homework & Coursework Questions

Bash shell - Check if value is valid directory.

1. The problem statement, all variables and given/known data: The script usage will be as follows: library.third source_directory - Your script will display an appropriate error message and exit with status 3 if no parameters are given - Your script will display an appropriate error... (2 Replies)
Discussion started by: netmaster
2 Replies

4. Shell Programming and Scripting

how to check for valid password

I need to check if an account has a valid password. Would something like this work? read ACCNAME if grep -q "^$ACCNAME:\$6:" /etc/shadow; thenI noticed every entry in my shadow file that has a password starts with $6 ... it works for my current setup, but would it always work? I can't test... (4 Replies)
Discussion started by: ADay2Long
4 Replies

5. Shell Programming and Scripting

Shell script that check the argument passed to it and prints error if test condition is not met

I want to make a script that check for the argument passed to it and generates an error in case any character/string argument passed to it. I am using below code, but its not working. can anyone help. #!/bin/bash if ]; then echo 'An integer argument is passed to the script hence... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

6. Shell Programming and Scripting

How to check the user input to be valid using shell script?

How to check the user input to be valid using shell script? The valid input is in the format like as follows. 1. It can only have r,w,x or a hyphen and nothing else. 2. ensure the r, w, x are in the correct order. for example: rwxr-xr-x is a valid format. Thanks (5 Replies)
Discussion started by: hyeewang
5 Replies

7. Shell Programming and Scripting

Passing variable as an argument to another script

Hi, I am trying to pass a variable as an argument to another script. While substitution of variable, I am facing a problem. varaiable "a" value should be -b "FPT MAIN". When we pass "a" to another script, we are expecing it to get substitue as ./test.sh -b "FPT MAIN". But, it is getting... (9 Replies)
Discussion started by: Manasa Pradeep
9 Replies

8. Shell Programming and Scripting

Check if time format is valid

How can I validate if time (HH:MM:SS) argument is valid? I got this from web but I can't modify it to exit the script if the time argument is invalid. echo $1 | awk -F ':' '{ print ($1 <= 23 && $2 <= 59 && $3 <= 59) ? "good" : "bad" }' ex: ./script.ksh 12:34:21 = okay ./script.ksh... (10 Replies)
Discussion started by: erin00
10 Replies

9. Shell Programming and Scripting

Check for valid hostnames

Hello, I am trying to develop a script to check for valid hostnames. Below are the prerequisites for a valid hostname which I got from wiki : Hostnames are composed of series of labels concatenated with dots, as are all domain names. For example, "en.wikipedia.org" is a hostname. Each label... (8 Replies)
Discussion started by: rahul2662
8 Replies
TCPSPRAY(1)							   User's Manual						       TCPSPRAY(1)

NAME
tcpspray - TCP/IP bandwidth measurement tool (Discard and Echo client) SYNOPSIS
tcpspray [-46ev] [-b block_size] [-d wait_us] [ -f filename] [-n count] <hostname> [port] DESCRIPTON
tcpspray uses the Discard resp. Echo protocol (RFC 863 resp. RFC 862) to perform bandwidth measurements of TCP sessions between the local system, and a Discard resp. Echo server. Unix-based hosts can provide a Discard and/or Echo servers with the Internet super-server inetd. On Windows NT, the simple network proto- cols optional component will do the same. The name or address of the server node must be specified. tcpspray will automatically try to use IPv6 when available. If not, or if it fails, it will fallback to IPv4. However, tcpspray4 resp. tcpspray6 only try to use IPv4 resp. IPv6. OPTIONS
-4 or --ipv4 Force usage of TCP over IPv4. -6 or --ipv6 Force usage of TCP over IPv6. -b block_size or --bsize block_size Send block of the specified byte size (default: 1024). -d wait_us or --delay wait_us Waits for the given amount of microseconds after any given was sent before attempting to send the next one. There is no delay by default. -e or --echo Use the Echo protocol instead of Discard. tcpspray will measure the time required to send data and receive it back, instead of sim- ply sending it. -f filename or --fill filename Read data from the specified file to fill sent blocks with. If the file is smaller than the size of blocks, or if no file were spec- ified, the remaining trailing bytes are all set to zero. -h or --help Display some help and exit. -n block_count or --count block_count Send the specified amount of data blocks for the measurements (default: 100). -V or --version Display program version and license and exit. -v or --verbose Display more verbose informations. In particular, tcpspray will print a dot each time a block is sent. If the Echo protocol is used (option -e), dots will be erased as data is received back. DIAGNOSTICS
If you get no response while you know the remote host is up, it is most likely that it has no Discard/Echo service running, or that these services are blocked by a firewall. Running tcptraceroute6(8) resp. tcptraceroute(8) toward the IPv6 resp. IPv4 remote host might help detecting such a situation. SECURITY
tcpspray does not require any privilege to run. SEE ALSO
tcp(7), inetd(8), tcptraceroute6(8), tcptraceroute(8) AUTHOR
Remi Denis-Courmont <remi at remlab dot net> $Id: tcpspray.1 658 2010-10-31 20:56:30Z remi $ http://www.remlab.net/ndisc6/ tcpspray $Date: 2010-10-31 22:56:30 +0200 (dim. 31 oct. 2010) $ TCPSPRAY(1)
All times are GMT -4. The time now is 11:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy