Sponsored Content
Top Forums UNIX for Dummies Questions & Answers checking if parameter passed is a number Post 302335474 by magnia on Sunday 19th of July 2009 02:09:07 PM
Old 07-19-2009
checking if parameter passed is a number

I have written a function that fills an array and another function where if a parameter is supplied it will jump to that part of the array and cat it to the screen.

I need to put in some checks to make sure the parameter supplied is firstly a number and then not a number great than the length of the array. if the user enters no value or anincorrect value it should be ignored and just cats out the entire array.

any ideas?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parameter Checking

Hi all, My script has 2 mandatory and 1 optional paramter. If the third parameter(optional) one is null the it should take a default value say 3. Can any one please write a simple code. sh test.sh 1 2 3 var1=$1 var2=$2 if then var3=3 fi echo " the third variable $var3" ... (1 Reply)
Discussion started by: ammu
1 Replies

2. Shell Programming and Scripting

manipulate a passed in parameter

I am passing a file name as a parameter to shell script the parameter is getfile.txt.gpg how do i process this parameter to get name like getfile.txt only and eleminate the .gpg text?? Thanks in advance (2 Replies)
Discussion started by: rudoraj
2 Replies

3. UNIX for Dummies Questions & Answers

checking parameter values passed to script

Hi, I will pass 3 parameters for a script.I have to check the file name and create a new file name with time stamp. the parameters which i'm passing are /dir/stg/filename.txt /dir/path/head.txt /dir/path/tail.txt Now i have to check filename like : if it is a.txt i have to create... (2 Replies)
Discussion started by: ammu
2 Replies

4. Shell Programming and Scripting

how to find the path of a file when it is passed as ....filename(parameter) to script

hi unix guru's..................:confused: question is posted in the #3 permalink shown below. (3 Replies)
Discussion started by: yahoo!
3 Replies

5. UNIX for Dummies Questions & Answers

ksh: verifying number of parameters passed

hi all, i have a ksh script that takes up to 3 parameters -- only 2 of which are required. what's the simplest way to check if the user passed 2 or 3 parameters? if 3 parameters are not null then do this elif 2 parameters are not null then do this else echo "you need at least 2... (5 Replies)
Discussion started by: ankimo
5 Replies

6. Shell Programming and Scripting

Detecting Doublequotes(") When passed as parameter to shell script

Hi, I am executing a shell script which takes a string as a parameter. The scipt should validate the string and create the directoy with the name of specfied string. The following is the specified command and its parameter. test.sh "abc abc" The shell script is not able to identify... (4 Replies)
Discussion started by: raghu.amilineni
4 Replies

7. Shell Programming and Scripting

How can i passed a parameter to a file?

i got a file called Pass1, and then i need to passed a number to my script with the '-p pass_mark' option. Example type Pass1 -p 18 to pass 18 to my script for comparing things, so how can i do it? (7 Replies)
Discussion started by: mingming88
7 Replies

8. Shell Programming and Scripting

Incrementing the date depending on the Counter (parameter) passed to the script

Hello Everyone, I have been trying to complete a shell script where, I need to increment the date depending on the file (depending on the date) availability on the remote server. i.e. Basically, I will be passing a counter (like parameter 1 or 2 or 3 or 4). First I will check for the... (1 Reply)
Discussion started by: filter
1 Replies

9. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

10. Shell Programming and Scripting

Resolving a parameter which is passed as parameter

Hi, I have the following files. ->cat scr.sh export TMP_DIR=/home/user/folder1 export TMP_DIR_2=/home/user/folder2 while read line do cat "$line" done<file_list.dat ------------------------ -> cat file_list.dat $TMP_DIR/file1.txt $TMP_DIR_2/file2.txt --------------------------- -> cat... (6 Replies)
Discussion started by: barath
6 Replies
getaddressconf(2)						System Calls Manual						 getaddressconf(2)

NAME
getaddressconf - Gets information about system address space configuration SYNOPSIS
#include <sys/types.h> #include <sys/addrconf.h> int getaddressconf ( struct addressconf *buffer, size_t length ); PARAMETERS
Points to an array of addressconf structures. Specifies the size in bytes of the array pointed to by the buffer parameter. DESCRIPTION
The getaddressconf() function fills in the array of structures pointed to by the buffer parameter with information describing the configu- ration of process address spaces on this system. This information is intended to be used by programs such as the program loader, which need to manage the contents of a process' address space using the memory management primitives such as the mmap() function. The buffer parameter points to an array of addressconf structures, occupying a total of length bytes. Each element of the array describes a single area of the process address space. The addressconf structure is defined in the sys/addrconf.h header file, and it contains the following members: caddr_t ac_base; unsigned ac_flags; The base virtual address of the area. For an upward-growing area, this is the low- est virtual address in the area; for a downward-growing area, this is the lowest virtual address above the area. The flags describe the area. They are also defined in the sys/addrconf.h header file, and are described as follows: The area grows towards higher addresses. The base address specified is the lowest address in the area. The area grows towards lower addresses. The base address specified is the low- est address above the area. The area always starts at the specified base address. For example, on many machines the text area is a fixed area. The area floats to the first available virtual address above the specified base address. For example, on many machines, the data area floats above the text area. Each element in the array of addressconf structures describes a separate area of the process' address space. These areas have been defined in the sys/addrconf.h header file; other areas may be defined in the future or on other machine types. The array elements are indexed with the following constants: The area that normally contains the text region of an absolute executable program. The area that normally con- tains the data region of an absolute executable program. The area that normally contains the bss region of an absolute executable program. The area that normally contains the process' user-mode stack. The area reserved for the text region of the default program loader see the exec_with_loader() function. The area reserved for the data region of the default program loader. The area reserved for the bss region of the default program loader. The area that normally contains text regions of relocatable files loaded by the program loader, or otherwise mapped using the mmap() function. The area that normally contains data regions of relocatable files loaded by the program loader, or oth- erwise mapped using the mmap() function. The area that normally contains the bss regions of relocatable files loaded by the program loader, or anonymous regions mapped using the mmap() function. The sys/addrconf.h header file also defines the AC_N_AREAS symbol to be the number of distinct areas currently defined for this system. Normally, the buffer parameter supplied to the getaddressconf() function should be large enough to hold information for AC_N_AREAS regions. If buffer is not large enough, the remaining information is truncated. The getaddressconf() call fills in the first AC_N_AREAS records in the user-supplied buffer with the address configuration information for this system, as described above. RETURN VALUES
Upon successful completion, the number of bytes actually written to the user's buffer is returned. If an error occurs, -1 is returned, and errno is set to indicate the error. ERRORS
If the getaddressconf() function fails, errno may be set to the following value: The address specified for buffer is not valid. RELATED INFORMATION
Functions: mmap(2), exec(2), exec_with_loader(2), brk(2) delim off getaddressconf(2)
All times are GMT -4. The time now is 10:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy