Outstanding work my European friend.
I just tried a more complex script with a for loop
and that also seems to work,
#!/bin/bash
declare IFS=$'\n'
ARRAY[0]="#!/bin/bash"
ARRAY[1]="declare -i INT=10"
ARRAY[2]="for (( i=0 ; i<INT ; i++ )); do"
ARRAY[3]="echo "hello""
ARRAY[4]="done"
eval "$(echo "${ARRAY[*]}")"
Getting back to the shebang, if I wanted to run a
perl script, would this work from within bash,
#!/usr/bin/perl
Thanks for all your help.
A.
---------- Post updated 16-01-10 at 09:30 AM ---------- Previous update was 15-01-10 at 02:23 PM ----------
Additional.
Found some perl and python scripts,
#!/usr/bin/perl -w
use strict;
print "Hello, Perl!\n";
#!/usr/bin/python
print "Hello, Python!"
but the method that worked for the bash scripts
doesn't seem to work for the other scripts.
Using the previous method with the perl script,
#!/bin/bash
ARRAY[0]="#!/usr/bin/perl -w"
ARRAY[1]="use strict;"
ARRAY[2]="print "Hello, Perl!\n";"
IFS="
"
script="$(echo "${array[*]}")"
eval "$script"
I get the following error.
Perl!n;: command not found
The same with the python script,
#!/bin/bash
ARRAY[0]="#!/usr/bin/python"
ARRAY[1]="print "Hello, Python!""
IFS="
"
script="$(echo "${array[*]}")"
eval "$script"
produces this error.
Python!: command not found
I tested the perl and python scripts in terminal and the
output was as expected.
Although I have *no* idea what I'm talking about, as an
alternative, I'm experimenting with redirection to bash
so that the script is executed from stdin if it is possible.
Any further help would be appreciated.
A.