Hi sk185094,
Scripts can be as complex as you like, a couple of things to keep in mind -
- ensure the commands you are running are repeatable or do not require interaction
eg.
Code:
cp rmkern /opt/gsctools/bin
- what happens when the file exists? change to:
Code:
cp -f rmkern /opt/gsctools/bin
- use test conditions to give yourself alternate actions
eg.
Code:
if [ -r /tmp/test ] # is file readable?
then
echo "File already present"
else
cp -f /tmp/myfile /tmp/test
fi
- send command output to /dev/null if not required
eg.
Code:
grep test /tmp/myfile > /dev/null 2>&1 # output not required
- you can find the return code of the last command by using '$?'
eg.
Code:
grep test /tmp/myfile > /dev/null 2>&1 # output not required
if [ $? -eq 0 ]
then
echo "Pattern found in file"
else
echo "Pattern not found"
fi
Putting your commands in a script:
Code:
#!/bin/bash
sum dkmscheck rmkern libbash > /tmp/my_file_sums_$(date +%F)
cp -f rmkern /opt/gsctools/bin
chmod 700 /opt/bin/rmkern
cp -f dkmscheck /opt/bin
chmod 700 /opt/bin/dkmscheck
mkdir –p /opt/lib/shell
cp -f libbash /opt/lib/shell
chmod 700 /opt/lib/shell/libbash
.. should get you started
cheers,
kbp