Question: Can I provide execute permission to a shell script while creating it for the first time?

I want a line of code which allows me to give execute permission to a file so that I can add that line inside the file itself. Assume that I know the filename beforehand.

Answer: 
Not sure if I understand you correctly, but if you want a script file that sets its own execution permission, you have to include this command:

```
chmod +x -- "$0"

```

The shell variable `$0` always holds the name of the running script. Note the double quotes and double dash to protect misinterpretation of special file names.

However, to launch that script the first time, you need to call the interpreter with the script file as argument, like this:

```
bash example.sh

```
```
chmod +x /path/to/file

```

If you are using a script to make a script you will not have a issue, however you can't use a script to give itself permission to execute, well you can but by that point it is pointless

you can also run a script lacking permission like this

```
sh /path/to/script.sh
bash /path/to/script
python /path/to/script.py
php /path/to/script.php

```