Korn Shell help - Using parameter to create variable names
I'm using korn shell and I am wondering if it's possible to use a parameter passed into a function to build a variable name in a configuration file. I have the function in one source file, I'd like to have a global configuration file instead of hardcoding logins to each script.
So I have a function, it accepts a system ID and I want to use that ID to read a configuration file for the server, user name and login for several different FTP sites. When I pass in the system ID of boe I then want to read the configuration file for boeServer, boeUser and boePassword but keep getting not found.
This is my source file functions:
Here's my config file ftpLogins:
And a simple script to call the function that I'm using:
This would allow us to essentially build one function that could FTP anywhere we need and if we FTP to that server more than once, we would have to make just one change.
That worked on the echo commands only. Now when I'm using the eval during the FTP, it's not reading the user name and password. I keep getting the error: 530 Please login with USER and PASS.
Seems like it's connecting to the server, I see some messages. But it's not recognizing the user name or password variables.
I was able to get the eval to work but no luck on the read. I'm curious because I don't want someone accidentally running a command. However, after a few hours of trying different combinations, read wouldn't resolve a string. Take the following sample, the script would just hang.
Per my samples where I pass in boe, I figured it would've resolved the ${system} to be boe and then look up boeServer in the ftpLogins file. In the end, I expect the variable server to have the value ftp1. While I'm happy for the eval solution, security wise I'd love to use read if I could.
I have written a script which will take input parameter as another script.
However, if the script passed as input parameter has parameters then this script doesn't work.
I have a script b.ksh which has 1 and 2 as parameters
I have a script c.ksh which has 3,4 and 5 as parameters
vi a.ksh... (1 Reply)
I have following files at /dir1
a.csv.20131201
b.csv.20131201
c.csv.20131201
d.csv.20131201
a.csv.20131202
b.csv.20131202
c.csv.20131202
d.csv.20131202
.......................
.......................
.......................
.......................
I need to move these files to... (4 Replies)
Hi
I am using two shell scripts which are running on the system simultaneously. And in one of the script i am exporting an Integer Variable.
Now i want to use the variable in another script. But i cannot run the first script in the second as the first script has many other functions which... (3 Replies)
Simple enough problem I think, I just can't seem to get it right.
The below doesn't work as intended, it's just a function defined in a much larger script:
CheckValues() {
for field in \
Group_ID \
Group_Title \
Rule_ID \
Rule_Severity \
... (2 Replies)
this is my issue.
4 parameters are passed from korn shell to sql script.
parameter_1= varchar2 datatype or no value entered my user.
parameter_2= number datatype or no value entered my user.
parameter_3= number datatype or no value entered my user.
parameter_4= number datatype or no... (5 Replies)
Hi
I have the following block of code in korn shell and don't now how to refer to variable `print variable1.$dvd` ?
---
integer dvd=4
integer number=0
while (( dvd!=0 ))
do
print "Iteracja numer : $dvd"
print "$_" #it refers to $dvd var but want to refer... (3 Replies)
I am using two shell scripts a.ksh and b.ksh
a.ksh
1. Sets the value
+++++++++++++++++
export USER1=abcd1
export PASSWORD=xyz
+++++++++++++++++
b.ksh
2. Second scripts calls sctipt a.ksh and uses the values set in a.ksh and pass to an executable demo... (2 Replies)
in a text " Korn Shell Unix programming Manual 3° Edition"
i have found this sintax to declare a compoud variable:
variable=(
fild1
fild1
)
but this sintax in ksh and sh (HP-UNIX) not work...
why?? exist another solution for this type of variable ??? (5 Replies)
Say I write something like the following:
var1=1
var2=2
for int in 1 2
do
echo "\$var$int"
done
I want the output to be:
1
2
Instead I get something like:
$var1
$var2 (2 Replies)