Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array scripting

Status
Not open for further replies.

riteshp

IS-IT--Management
Aug 24, 2000
25
0
0
US
Hi,

I need help with a script I have to write. I have to take arguments provided by the user and break them up in 2. So if user types:
script_name -S some_string -c some_string -D some_string

I have been so far able to do
fo arg in "$@"
do
val='echo ${arg} |sed -e "s/-[A-Za-z]//"'
case ${arg} in
-a*) .....;;
-C*) .....;;
esac
done

This gives me the string right after the option suppiled, and I can do cut to get the option, then define all uppercase and lowercase characters in my case statement, but that is too long. What I wan to do is take the suppiled iformation such as :

script_name -S some_string -c some_string -D some_string

place the option in one array and the string in another array. This way the user can reference the information from the array at any time and more importantly ANy USER can use this script. I also need to add a counter which will be used to verify the number of actual number of options/commands inputted versus the actual number processed.

I hope some can take time and help me....

TIA


 
Consider perl a better solution for this program, as it is no longer a little script. The handling of arrays in the classic unix shells was one reason for me to invest some time in learning perl... You can compile it and put in /usr/local/bin/ without being afraid to be compromised).

What will that script do when it is finished?
regards
chenn
 
It's supposed to take the commandline arguments and plac options in one array and the arguments in an corresponding array. Arguments could be for example:
-aservername -Tservertype -hf file_name -t

the option could even have no arguments like -t above. This script should take all those things into account and place that info in the array accordingly. The end result should be a GENERAL script which will do the above so any user(whether a Unix or a Database user)can use the script.

Any suggestions.....
 
easy to do in perl, if you want to go that way, and it could be written so that you'll have that routime available to all your perl scripts Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Forget about all perl and awk ideas, try learning the [tt]getopt[/tt] command available on [tt]ksh[/tt] and [tt]bash[/tt] shells.

I hope it works...
 
hi, anybody knows if the machine need to be rebooted after the ulimit command.

I have set all resource unlimited but the max file size is still 1M which is the value before changes

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top