Prathyush Pv
Prathyush Pv

Reputation: 69

Command line argument No such file or directory error in bash

I have written a bash script and when it is executed as

./script a b c

it is working fine. then I moved the script to the bin folder and tried to execute it as

script a b c 

now it is showing error

a: No such file or directory
b: No such file or directory
c: No such file or directory

Any ideas on how to fix this?

Upvotes: 1

Views: 2254

Answers (2)

Rakib
Rakib

Reputation: 2096

You execute your script with file as a parameter. When you execute by using

$ ./script a b c 

parameter file and script are same location. after moving the file bin folder may be execute script from different location where your parameter file not there.

So execute your script with location of file

$ script /path/of/a /path/of/b /path/of/c

then it will be worked fine.

Upvotes: 0

Cyrus
Cyrus

Reputation: 88776

Rename your script. I suppose program script is installed on your system.

See from your bash: man script

Upvotes: 1

Related Questions