I am very, very new to shell scripting, but what I'm attempting to do is read in a list of user ID's to create on a database system from a CSV flat file, and for each entry run the "create user" script. I've gotten pretty far but I'm having trouble with the looping mechanism.... Any input would be greatly appreciated.
The rest of the code is a SQL script that uses ${ID} as the username. How do I wrap the SQL script into the loop so that it will execute the script for each entry in the file?
Things that work as expected are: passing the variable into the SQL script (was able to run some tests and get it working), and executing the SQL script from the .ksh against the target database system.
Thanks in advance.
*edit*
Edited to add, currently it sets the variable ${ID} as every item in the CSV file, without the commas and with a space inbetween, which of course causes a syntax error in the SQL.
What you need to do is build up a file with the appropriate commands and then feed that to bteq afterwards.
Something like this. Notice how you need lines in order for the whileloop to work as you imagine, so I made each entry a new line instead of it being on the same line.
Hi guys!
Kind of new to bash scripting and now I'm stuck.
I need to curl with these variables:
"{ \"nodename\": \"$1\", \"ipaddress\": \"$2\", \"poolname\": \"$3\", \"port\": \"$4\", \"loadbalancer\" : \"$5\" }"
and my input_file.txt contains
server001 10.10.10.01 serverpool1 80... (4 Replies)
Heya
I'm using Awesome WM with the Vicious widget library.
As i'm using multi boot, Win8, Fedora and Arch, i have my WM-Config shared accross my GNU/Linux installations.
The regarding snippet:
-- Functions
-- Its just a workaround for an 'unstable' 'hwmon/hwmon' definition of Fedora21 -... (0 Replies)
Experts,
I want to set value of variables like this in bash shell:
i=5 ; L=100
I want variable d5 (that is d(i) ) to be assign the value of $L ,
d$i=$L ; echo $d5
Not working
Thanks., (3 Replies)
Hi
Could you please tell me how to set environment variables in Unix ksh.
And how can acess those varibles in shell scripts
( Please give the code with an example)
For my scenario.
We have written number of shell scripts with hard coded username and password.
But if we want to... (1 Reply)
Hi,
I'm using a for loop reading from an input file that contains files, whose path includes a variable name.
But the for loop doesn't expand the variable and therefore can't find the file.
Here's an example:
File BACKUPFILES
/home/John/alpha
/home/Sue/beta... (8 Replies)
Hi,
does anybody knows how to manage, that the filenames are assigned to a variable in a loop afer getting them with set command in a ksh, like:
set B*.txt
i=1
c=$#
x=$((c+1))
echo "$x"
while ] ; do
_ftpfile$i="$"$i
echo "$_ftpfile$i"
i=$((i+1))
done
The first echo returns,... (2 Replies)
I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends.
As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Sorry for such a dreadful title, but I'm not sure how to be more descriptive. I'm hoping some of the more gurutastic out there can take a look at a solution I came up with to a problem, and advice if there are better ways to have gone about it.
To make a long story short around 20K pieces of... (2 Replies)
Hi -
I'm trying to think of a clever way to write a shell script (trying to stay w/ ksh as that's what I know the best...) that will resolve the following problem:
Problem - On a daily basis I have to email folks who are on-call to remind them. I was hoping to script this out so I could have... (9 Replies)
I have a script that I'm trying to shorten (below) by removing repetitive code.
if ]
then
commodity_ndm_done=Y
fi
if ]
then
customer_ndm_done=Y
fi
if ]
then
department_ndm_done=Y
fi
if ]
then
division_ndm_done=Y
fi (3 Replies)