Changing the current working directory of a running process

no7892142

New Member
Hello,

first and foremost, I have read http://knowledgebase.progress.com/articles/Article/P9223 regarding this, but couldn't figure out a proper solution for a unix-based system (or maybe just which external procedure I need to use in that case).

I need to programmatically change the working directory of a process for a bit, so I can generate a properly structured archive file from there (invoking 'tar' with absolute paths yields a complete folder structure within the archive while I only want it starting from the directory that is going to be archived).
I'm still looking through the 'tar' man pages but no luck so far, so I'm starting to believe this is the only option.

Very much appreciating any help.
 

no7892142

New Member
Hm, unless I'm missing something, this still executes the tar command within the folder the tarcmd.p exists in.
Thanks for the suggestion though.

Temporaily moving it to the folder where I want the tar command executed could probably work, but I want to avoid that if possible.
Another similar way of doing this would be to copy over what I need into my working directory, tar from there, and then copy it back to where I want it.
This all does seem needlessly complicated, though.
 
Last edited:

RealHeavyDude

Well-Known Member
Are you executing the tar command directly from os-command ?

I never do that. For one because os-command provides no error handling ( doesn't return the exit status ). And secondly, because you almost never have the correct environment the os command expects - which in your case is the working directory.

I always create a shell script in the ABL on the fly and write it to an OS file and then executed that script. The last thing such scripts do, is to remove a file that was touched at the beginning when the real os command ( tar in your example ) returns with exit status 0. That way I know whether there has been an error or not. I can even write details of the error into a file in the script which is then picked up by the ABL to log the error accordingly or present the user with a meaningful error message.

Heavy Regards, RealHeavyDude.
 

no7892142

New Member
Yeah, I've been considering doing something along those lines, too. But that's usually one step later, after the actual functionality is there.
Currently, I'm doing what little debugging/error-checking I do by reading the screen output (i.e. inputting the command via INPUT THROUGH).

However, even if I were to generate a shell script, I'd have to put it one level above the directory that I want to archive in order to create the necessary structure within the archive.
Which in turn leads to the initial problem that I really only want to switch my working directory, tar, and switch back.
Thanks for the addtional tip though, I'll keep it in mind.
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
I think you can put the shell script wherever you want and have it cd to the appropriate directory before running tar.
 

no7892142

New Member
Doing it with a shell script works like it should, so thanks again for the help everyone.
Even though I'm still curious about the possibility to change the working directory entirely.
 
Top