Error in ksh script

Posted on 2004-11-22
Last Modified: 2013-12-26
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.
Question by:jc31415
    1 Comment
    LVL 20

    Accepted 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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now