#!/bin/bash
if [ -z $1 ]; then
echo 'Enter something please.';
exit 1;
fi;
if [ -z $1 ]; then
echo 'Enter something please.';
exit 1;
fi;
$(), which I find easier to read, and allows for nesting.OUTPUT=$(ls -1)
echo $OUTPUT
eval to execute a string:eval $illcommando
echo "${array[0]}"
To iterate over the elements:for element in "${array[@]}"
do
echo "$element"
done
To get both the index and the value:for index in "${!array[@]}"
do
echo "$index ${array[index]}"
done
The last example is useful because Bash arrays are sparse. In other words, you can delete an element or add an element and then the indices are not contiguous.unset "array[1]"
array[42]=Earth
INPUT=hosts_test.cvs
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read privateip password
do
sshpass -p$password ssh -t -o "StrictHostKeyChecking no" user123@$privateip "
hostname
hostname -I --all-ip-addresses
sudo yum -y update bash
env x='() { :;}; echo vulnerable' bash -c \"echo If you see the word vulnerable above, then you are vulnerable to shellshock\"
echo ""
exit
" >> output.txt
done < $INPUT
IFS=$OLDIFS
10.xxx.xx.219,abcd~qY1
10.xxx.xx.226,l4~abcdefg
10.xxx.xx.221,l4@abcdefgh
</dev/null.
Hello Friends! I am Ramana a part time blogger from Hyderabad.