So I have a ksh script that needs to be in a certain dir before executing another script. I tried to code the cd command using a variable and it does not work ... what am I doing wrong? Below is a copy of a simple script put together. Notice that line 9 does not work while and line 14 does work. Also notice that line 15 and 20 do not work, but they previously wored in lines 7 and 11. So I am confused.
Any idesa?
1#!/bin/ksh
2#set -x
3CD=/usr/bin/cd
4ECHO=/usr/bin/echo
5PWD=/usr/bin/pwd
6${ECHO} >> ${log_name}
7${ECHO} "Test 1 Current Directory is `${PWD}`" >>
${log_name}
8${ECHO} >> ${log_name}
9${CD} /export/home
10${ECHO} >> ${log_name}
11${ECHO} "Twst 2 Current Directory is `${PWD}`" >>
{log_name}
12${ECHO} >> ${log_name}
13cd /export/home
14${ECHO} >> ${log_name}
15${ECHO} "Test 3 Current Directory is `${PWD}`" >>
${log_name}
16${ECHO} "Test 3 Part 2 Current Directory is `/usr/bin/pwd`"
>> ${log_name}
17${ECHO} >> ${log_name}
18/usr/bin/cd /export
19${ECHO} >> ${log_name}
20${ECHO} "Test 4 Current Directory is `${PWD}`" >>
${log_name}
21${ECHO} "Test 4 Part 2 Current Directory is `/usr/bin/pwd`"
>> ${log_name}
22${ECHO} >> ${log_name}
Output from script execution, itheratice at terminal
Test 1 Current Directory is /export/home/sysadmin/script/common
Twst 2 Current Directory is /export/home/sysadmin/script/common
./sds[15]: /export/home: cannot execute
Test 3 Current Directory is
Test 3 Part 2 Current Directory is /export/home
./sds[20]: /export/home: cannot execute
Test 4 Current Directory is
Test 4 Part 2 Current Directory is /export/home
Any idesa?
1#!/bin/ksh
2#set -x
3CD=/usr/bin/cd
4ECHO=/usr/bin/echo
5PWD=/usr/bin/pwd
6${ECHO} >> ${log_name}
7${ECHO} "Test 1 Current Directory is `${PWD}`" >>
${log_name}
8${ECHO} >> ${log_name}
9${CD} /export/home
10${ECHO} >> ${log_name}
11${ECHO} "Twst 2 Current Directory is `${PWD}`" >>
{log_name}
12${ECHO} >> ${log_name}
13cd /export/home
14${ECHO} >> ${log_name}
15${ECHO} "Test 3 Current Directory is `${PWD}`" >>
${log_name}
16${ECHO} "Test 3 Part 2 Current Directory is `/usr/bin/pwd`"
>> ${log_name}
17${ECHO} >> ${log_name}
18/usr/bin/cd /export
19${ECHO} >> ${log_name}
20${ECHO} "Test 4 Current Directory is `${PWD}`" >>
${log_name}
21${ECHO} "Test 4 Part 2 Current Directory is `/usr/bin/pwd`"
>> ${log_name}
22${ECHO} >> ${log_name}
Output from script execution, itheratice at terminal
Test 1 Current Directory is /export/home/sysadmin/script/common
Twst 2 Current Directory is /export/home/sysadmin/script/common
./sds[15]: /export/home: cannot execute
Test 3 Current Directory is
Test 3 Part 2 Current Directory is /export/home
./sds[20]: /export/home: cannot execute
Test 4 Current Directory is
Test 4 Part 2 Current Directory is /export/home