Dongho Han
Dongho Han

Reputation: 97

How can I run executable in shell script?

I have folder "destination/" and inside the destination folder, it contains executable grade1. My current directory is "destination/"

I'm Trying to run

for i in FILES/*; do ./grade1 $i done

Which it keep says

./grade1 no such file or directory

Weird part is that, when I just copy the code to command line and run it, it works fine. Problem only arises when I do it in shell script

Upvotes: 2

Views: 6959

Answers (2)

user1934428
user1934428

Reputation: 22301

I don't think that grade1 really is in your current working directory, as you claim. I suggest that you verify this also check the permissions of your executable. Extend your code to

echo current directory is $PWD
ls -l grade1
for i in FILES/*; do ./grade1 $i done

This should reveal the source of your problem.

Upvotes: 1

nagendra547
nagendra547

Reputation: 6330

One simple way to fix this problem might be to start using FULL path of grade1 executable file

for i in FILES/*; do {FULL_PATH}/grade1 $i done

Upvotes: 0

Related Questions