TheFoxx
TheFoxx

Reputation: 1693

Execute something from path in a specific directory in linux

I was wondering if it was possible to execute something from path in a specific directory, e.g. I have a program called STAR in my path on linux, and I have a sh script written to execute it multiple times, however when it runs it generates the output (which is composed on multiple files) in the current working directory. Now there isn't any built in functionality in the program itself for redirecting the output.

Any ideas? Thanks in advance!

Upvotes: 0

Views: 171

Answers (1)

FatalError
FatalError

Reputation: 54551

The cwd is changed using the underlying chdir() system call, which is called by cd in your shell. If the script dumps to the cwd and you want it to dump somewhere else, just use cd in your wrapper script to change to the directory where you want the output.

Upvotes: 3

Related Questions