Hallo everyone,
I am running an SQL-Script over KShell-Script. Thus, in the KShell-Script there are these lines:
WORKPATH=$PWD/work
EXPORTDIR=export_meine_datei_bitte
EXPORTPATH=${WORKPATH}/${EXPORTDIR}
...
db2 connect to ${DBNAME} || die "can not open database connection"
db2 -tf sql_script.sql || die "comments"
...
In my SQL-Script it exists an export command:
export to ./tabelle.csv of del
...
...
As we can see, I have defined some variables, but uncompletely, such as WORKPATH is still unfilled. It is because, that the KShell-Script should be run in ANOTHER Unix-System. Now, the SQL-Script creates for a csv-table to the directory, which where the SQL-Script last being called. But the SQL-Script should create the csv-table in the variable EXPORTPATH.
So, thats why I was thinking, "okay, then I will just do a cd ${EXPORTPATH} bevor calling the SQL-Script:
...
cd {EXPORTPATH}
db2 connect to ${DBNAME} || die "can not open the database connection"
db2 -tf sql_script.sql || die "comments"
...
My teacher, who is a UNIX-Guru, said, this is not good. He gave me the reason for it but I could not understand. I try to explain the reason:
"if you do a cd there, it would be NOT RELATIVE PATH SAFE, it must be relative path safe. You are possibly killing all the relative paths, which come from outside."
It is difficult for me to express my question correctly becaus I actually dont even understand what the basic problem here. Does somebody have a clue? He is a UNIX-Guru, so it must be something true in his explanations.
As I said, the KShell-Script should be run in the machine, which I dont know the config-files and environment variables.
I hope, someone can help me.. Thank you.
Regards,
Ratna:)