Running a script with multiple variables like 25 variables.
Hi All,
i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way??
so while running scripts i have to give like below.
now problem is that position of these arguments can change while passing to script
You also need to be away that referring to positional parameter $25 will usually end up being interpreted as ${2}5, i.e. the value of parameter two, followed by the literal value 5.
Someone in their wisdom here managed to code scripts that look like this:-
The idea being that the month is passed in as positional parameter 2 and the year is appended. Apart from looking awful, of course we then ended up editing the script each year - oh, and the year was not necessarily the calender year that the process was running in either.
It works for us (very badly and will be replaced soon) but you might get very confused by the use of:-
.... giving you the output gM5
The standards state that positional parameters with more than a single decimal digit must be specified with braces. I.e., ${25} will expand to the value of the 25th positional parameter and $25 will expand to the value of the 2nd positional parameter followed by the string 5.
Rather than writing code that uses $25 to append "5" to the expansion of $2, I write it as ${2}5 to make it less likely to confuse people who read my code; but experienced shell programmers should know how this works.
Is it possible to have a user input multiple words in one line and have the script assign each word a variable? I'm stuck please assist.
Example using "BILL JOHN SARA JILL" as what the user could type:
printf "Enter account names: " BILL JOHN SARA JILL
read input (9 Replies)
how to store the count of queries in variables inside a filein shell script
my output :
filename
-------
variable1=result from 1st query
variable2=result from 2nd query
.
.
.
. (3 Replies)
I'm pretty new to scripting in Korn shell so please forgive me...
What I'm trying to do is to create a script that calls multiple other ksh scripts and defines variables for text files.
I need it to define my user defined variables (file paths, date & time stamps, etc that are currently in... (1 Reply)
Hey all,
Unfortunately I have only basic knowledge of awk and/or scripting. If I have a file with lines that can look similar to this:
Name=line1 Arg1=valueA Arg2=valueB Arg3=valueC
Name=line2 Arg1=valueD
Name=line3 Arg1=valueE Arg3=valueF
Name=line4 Arg2=valueG ... (4 Replies)
Hello, I am new to the whole "scripting" thing. Below is the script that I have so far and where i need the Variables to go (VAR#)
#!/bin/bash
#Sample Script
VAR1=
echo "Choose an option: 1) Create a file. 2) Delete a file. 3) Move a file."
read VAR1
case $VAR1 in
1)
echo "Pick... (4 Replies)
This is for an Oracle journal import. I was using a pl/sql package and oracle API's. Oracle added invoker rights to their API's and now my package won't run. I didn't want to use their API's anyway. The only reason i was using pl/sql and the API's (just a package) was to utilize a cursor. How... (2 Replies)
I have created a script that prompts the user to enter three variables that are seperated by a space as the delimiter.
It then performs a command 3 seperate times for each variable entered.
I want the script to llow the user to enter as many variables as they may like and the script to... (5 Replies)
Hi All
Some how, variables are not getting exported while running the script in cronjob. Variable value is coming blank. But the variables are geting the value when the same script I am running manually. Any idea why?
When running the script in cron-job
==================================... (7 Replies)
I am trying to close of multiple users in an Oracle database. Each users has records in multiple tables what I need to do is use a script that call each SQL seperately passing either CLI arguments or gathered arguments from the users during run time.
## Accept variable(s) from the command line... (1 Reply)