# What about nested shebangs?



## freethread (Mar 26, 2010)

I have a perl script that execute another script in javascript. To execute the javascript script I type:

```
# jsexec.pl example.js
```
Ok, it works. Obviously the *jsexec.pl* has the shebang *#!/usr/bin/perl*. To have to type only the javascript script to run it on command line I added a shebang in *example.js* (and skipped it in perl parser) and *chmod a+x example.js*. The perl script *jsexec.pl* is in */root/bin* so the shebang is *#!/root/bin/jsexec.pl*. It doesn't work and strange things happens.

I made two test scripts


```
[B]Perl script (sbang.pl)[/B]

   #!/usr/bin/perl

   use strict;
   use warnings;

   print ("--- sbang.pl ---\n\n");
   for (my $i = 0; $i < @ARGV; $i++)
   {
      my $sParam = $ARGV[$i];
      printf (" %04i - %s\n", $i, $sParam);
   }
   print ("--- end ---\n\n");
```


```
[B]Javascript script (sbang.js)[/B]

   #!/root/bin/sbang.pl

   printf ("%s %04X", "this is a test", scalar @ARGV);
```

Yes, in the javascript script file there is a perl instruction, executing it with

```
# sbang.js
```
the result is

```
Badly placed ()'s.
```

Searching on google/yahoo found no help.


----------



## freethread (Mar 26, 2010)

Solved. Modified shebang in *sbang.js* to


```
#!/usr/bin/perl /root/bin/sbang.pl
```


----------

