|
|
Question : passing an array as argument to shell script
|
|
I want to pass an array as argument to a shell script. And loop through the array within the script for processing.
running the script: script.ksh array
#!/bin/ksh
for array do processing done
Please advise.
|
Answer : passing an array as argument to shell script
|
|
this should work with spaces or commas or both (but a space is still needed between servername and the first client)
#!/usr/bin/ksh server=$1 shift IFS=" ," for client in $* do echo $client ssh $server "ptree $client" >> results.temp.$$ for process in process1 process2 process3 do if grep $process results.temp.$$ >/dev/null then : # Process Exists else echo $client $process missing >> client_report.out fi done
done rm results.temp.$$
|
|
|
|