I have read the contents of a folder and store them in an array. And need to pass this array to a script. How can I store and pass the array and read that array??
#!/usr/bin/ksh
cd /path/applications-war
arrayWar=( $(ls /path/applications-war))
I need all the contents under this folder into an array (@arrayWar). I will login into another box and call a script. I need to pass this array to the script.
/usr/bin/ssh -t -t username@machinename /path/myscript.sh @arrayWar
Inside myscript.sh, I want to compare the passed array @arrayWar with ServicesArray.
#!/bin/ksh
@arrayWar = $1
ServicesArray=('abc.war' 'xyz.war')
for warfile in @arrayWar
do
if echo "${ServicesArray[@]}" | fgrep "$warfile"; then
echo "$warfile matches"
else
echo "$warfile not matched"
fi
done
=sign? Don't you get an error message? Good luck."${arrayWar[@]}"(double quotes essential) expands to the contents of that array.