[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 698
  • Last Modified:

Error in ksh script

I am running on IBM's AIX, a variant of unix.
In dir1/dir2 I have two files, test.cmd and test. The contents of test.cmd is:
pdpr -d $1 test
If I am in dir2 and issue the command ksh test.cmd prt, everything works correctly. If I am in dir1 and issue the command
dir2/test.cmd prt, I get the following error:
Cannot open file test.
Both file test.cmd and test have permissions 777.
Why is that happening and how can I fix it.
1 Solution
`dir2/test.cmd prt` is executed in your current environment, i.e. in dir1; So it's looking for (and  failing to find) the data file "test" in dir1.

To fix it, you need to give the path to the file test within the script, e.g
pdpr -d $1 /dir1/dir2/test
Or, within the script, cd to the directory before running the `pdpr` command

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now