Informing the IBM Community

/Home bitter-sweet /Home

0
(0)

The Home directory is nothing new to IBM i, it’s been around for decades and yet it is not widely used. With the increase in popularity of Open Source on IBM i (including SSH) this is changing and many more users are creating their Home Directories and some are noticing an unexpected side effect.

What is the problem?

If you notice that suddenly your IFS commands stop working the way they have been it could be because you’ve created the home directory for the user that is running the job and if the IFS path was not fully qualified then the home directory is prepended to the path used in the command.

Put simply, if you were using a path of ‘MyFiles/Input’ and you created a home directory for user BRAD, you might find that when you run the command under user BRAD it changes the path to ‘/home/BRAD/MyFiles/Input’

How do you avoid this?

The answer is simple and many of you will have been doing this from the start and so will not fall foul of this. It is to you specify a fully qualified path name in your command.  That is a long winded way of saying the path needs to start with a / (forward slash).  So, in the example above if I had specified ‘/MyFiles/Input’ instead of ‘MyFiles/Input’ then the problem would not occur.

What and where is the Home directory?

OK, let me take a step back for a moment and fill in some background, if you know what and where the Home directory is, then I’d skip to the next section.

IBM created the Home directory to support the AIX PASE environment, it is the Unix / Linux equivalent of a Current Library.  

By default, IBM i ships with a directory called ‘/home’. 

By default, when you create a user profile in IBM i the home directory is ‘/home/{UserProfile}’

ProTip: If you want to know what home directories are step onto your system, try using the following command:
WRKLNK ‘/home/*’

What’s Occurring?

When you create a user profile in IBM i, by default it does NOT create the home directory for this user, which is understandable, but here (in my opinion) is the weird thing:

If the home directory for the user profile does not exist, IBM i DOES NOT prepend the home directory to the path but the next time the user signs on after the Home directory is created, it does.   

You can test this easily enough by using the WRKLNK command. If you type WRKLNK with no other parameters and press Enter, it will show you what IBM i currently interprets as your Home Directory.

If your home directory does not currently exist, then WRKLNK defaults to the root directory ‘/’ as shown below:

If the Home directory for the user running the command does exist, then WRKLNK will default to that directory, as shown below:

Can you check / change a user’s Home directory?

It is easy enough to check or change a user’s Home Directory.  It is specified on the last page of User Profile details.  So, you can check what it is currently set to using the DSPUSRPRF command.

In the example below, I used DSPUSRPRF BRAD and then paged down to the bottom of the information displayed to show that my home directory follows the default pattern of /home/{UserProfile}.

If desired, I could change this using the CHGUSRPRF command, an example shown below but I would not recommend this unless you have a really good reason as some Open Source software will expect the Home directory to be in the default location.

CHGUSRPRF USRPRF(BRAD) HOMEDIR(‘/NotAgoodIdea’)

What commands are affected?

As far as I can tell, it’s call commands that have an IFS path. The most common ones I find people have problems with are CPY, MOV, RNM, CPYTOIMPF, CPYFRMIMPF, CPYTOSMTF, CPYFRMSTMF, CPYTOARCF, CPYFRMARCF.

A typical example of this problem

In the example below, I did not specify a fully qualified name for the object I wished to rename, this would work just fine if the user running the command did not have a Home directory that existed on this system but would fail if it did with an object not found.

The more eagle eyed of you will note that the error message is not helpful, as it does not show the prepended Home Directory path.  It would be more helpful if in this case it had returned the real problem:
“Object not found.  Object is /Home/BRAD/tmp/areDodReport.txt.”

Just to prove the point, if the Home directory had not existed for the user running the command, the rename would have worked.

What can you do to fix or mitigate this issue?

Well to fix it, really you should use a fully qualified path name, i.e. make sure your path starts with /
That’s OK for the command line but if you have a lot of CL Programs compiled like this, then you really only have two choices. Either delete the Home directory or run the program under another user that does not have a Home Directory that exists.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *