0

i am working on ksh in Sun Solaris. i have a file having only one word as job names per line. want to read all the jobs from the file and execute them one by one in the given orde. how to do it in ksh. the below code works fine if fired on the command prompt. when i try to run it through shell script it gives error.

i=0;nawk '{print $1}' input.txt | while read -r r;
do 
a[i]="$r";
echo "${a[++i]}";
done

ERROR:

i=0
+ read -r r
+ nawk {print $1} input.txt
test2.ksh: -r: is not an identifier
glenn jackman
  • 238,783
  • 38
  • 220
  • 352
atul
  • 1
  • 1

1 Answers1

0

The message is coming from Bourne shell, so probably somehow the script does not get called in the right way. You would need to insert a shebang as the first line in the script:

#!/bin/ksh

and make it executable and execute it:

chmod +x /path/to/script
/path/to/script

or you would need to call the the script like this:

ksh /path/to/script
Scrutinizer
  • 9,608
  • 1
  • 21
  • 22