# executing script in linux



## leedude (Aug 18, 2006)

i think i remember something from somewhere that was written kinda like this:

prog1:

```
#!/usr/bin/perl

print "hello"
```
how do i make it so that i can just type ./prog1, if i do that, it says permission denied, even in root user.


----------



## leedude (Aug 18, 2006)

*-*

-----


----------



## shuuhen (Sep 4, 2004)

chmod is the command to change permissions. Your little script doesn't have execute permissions. You can check permissions with 'ls -l' (without quotes, and those are lowercase L's).

chmod +x adds execute permissions for all users. Without execute permissions, everyone will be denied.


----------



## leedude (Aug 18, 2006)

thanks, one more thing, can you do the same with c++?

something likeprog1)

```
#!/usr/bin/g++ -E(preprocess only)

#include "iostream"

int main() {
cout << "hello\n" << endl;
}
```


```
./prog1
```
this produces an error from g++ saying that the linker input file was unused because linking not done.


----------



## shuuhen (Sep 4, 2004)

Can't think of how that would work. Only way I've ever used C/C++/etc. is by compiling the source code. Compiled programs will run better that interpreted ones.


----------

