script arg or parameters limitation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script arg or parameters limitation
# 1  
Old 04-22-2012
script arg or parameters limitation

Hi,

I would like to ask some info on the script arguments/parameters. Does script arguments had limitation like inside or deep inside the loop in which it will not function as it use to be.

as an example:
$2 not working
Code:
command2 () {
for log in $LOG{1,2,3}
	do
	if [ -e $log ] && [ -s $log ]; then
	echo
	echo BEGIN $log
	grep -E "$DATE" $log | grep -E "$2"  2> $SCRIPT
	echo
	echo END $log
	echo
	fi
	done
}

$2 need to declare as another variable to work

Code:
par2=echo $2
command2 () {
for log in $LOG{1,2,3}
	do
	if [ -e $log ] && [ -s $log ]; then
	echo
	echo BEGIN $log
	grep -E "$DATE" $log | grep -E "$par2"  2> $SCRIPT
	echo
	echo END $log
	echo
	fi
	done
}

# 2  
Old 04-22-2012
Call the function with the parameters of the script to use them as $1, $2....in your function.
Code:
command2 "$1" "$2"

This User Gave Thanks to Franklin52 For This Post:
# 3  
Old 04-22-2012
@Franklin52: thanks thats all i need..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python script for sendmail limitation

Hello, I have a web server (apache, php-fpm) with several vhosts sending mail through php. In order to avoid IP blacklisting when spam is sent by a domain i'm looking for a way to setup a rate limit for outgoing mail and when this limit is reached I want to receive an email warning me that a... (1 Reply)
Discussion started by: draugr
1 Replies

2. Shell Programming and Scripting

Shell script to create runtime variables based on the number of parameters passed in the script

Hi All, I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them abc.sh ---------- export Numbr_Parms=$# export a=1 while do export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

3. Shell Programming and Scripting

Bash script too many arg's

I have a simple bash script on RHEL that works fine when there is one file but when it finds multiple files of same condition I get too many args error. for i in * do if ;then echo "no files to move" exit 0 fi if ; then ... (10 Replies)
Discussion started by: jcalisi
10 Replies

4. UNIX for Dummies Questions & Answers

Shc script size limitation and "_SC_ARG_MAX (see sysconf(2))" parameter

I wish to change the parameter (which I do not understand exactly what it is and I wish to) and be able to use shc with very long bash scripts (2 Replies)
Discussion started by: frad
2 Replies

5. Shell Programming and Scripting

ksh script throwing arg list too long for mv cp wc - everything

i have a ksh script which internally calls another ksh script. this inner script has simple commands like shown in the code window. In the script im trying to do a mv - it fails with arg list too long. then i try to perform cp and cat - and both are failing with similar error. :wall: How is... (4 Replies)
Discussion started by: nyc68
4 Replies

6. Programming

warning: int format,pid_t arg (arg 2)

I try following code under Solaris10,like follows: int glob = 6; int main(void) { int var; pid_t pid; var = 88; printf("before vfork\n"); if ((pid = vfork()) < 0) { err_sys("vfork error"); } else if (pid == 0) { glob++; var++; _exit(0); } ... (1 Reply)
Discussion started by: konvalo
1 Replies

7. Shell Programming and Scripting

How to pass an array as arg to a script..

Hi, Please guide to pass an array as a arg to a script... for example, I have a script small.sh to find the small no of given arg as below... #! /bin/sh # this script is for finding the small number set -A arr_no_updates small=$1 i=1 for arr in $@ do if (3 Replies)
Discussion started by: little_wonder
3 Replies

8. Shell Programming and Scripting

help me in sending parameters from sqlplus script to unix shell script

Can anybody help me out in sending parameters from sql*plus script to unix shell script without using flat files.. Initially in a shell script i will call sql*plus and after getting some value from some tables, i want that variable value in unix shell script. How can i do this? Please tell me... (2 Replies)
Discussion started by: Hara
2 Replies

9. HP-UX

HP-UX 11i - File Size Limitation And Number Of Folders Limitation

Hi All, Can anyone please clarify me the following questions: 1. Is there any file size limitation in HP-UX 11i, that I can able to create upto certain size of file (say 2 GB) and not more then that???? 2. At max. how many files we can able to keep inside a folder???? 3. How many... (2 Replies)
Discussion started by: sundeep_mohanty
2 Replies

10. Shell Programming and Scripting

Limitation of DiskSpace Script

Hi, I'm a teacher in Germany and I want to set up a classroom with Linux 8.1 PCs. Every User should have a Max of 100 MB available space. Now I need a script which tells everyone how much diskspace is used in a certain subdirectory. It should work like that: User enters a command like... (1 Reply)
Discussion started by: Dansen
1 Replies
Login or Register to Ask a Question