DATE=`date '+%y%m%d'`
TIME=`date '+%k%M'`
using awk
LIST=`awk '{print $1}' file`
for OBJECT in ${LIST}
do
echo OBJECT
done
the default awk uses a space, using other separators, use a -F
calling sqlplus
sqlplus -s /nolog <
connect / as sysdba
set echo off embedded on feedback off heading off linesize 120 pagesize 0 recsep off verify off termout off
EOF
calling ftp
ftp -nv 147.132.19.52 <
prompt
asc
get file
bye
EOF
mail alerts
mailx -r "reply.to@host.com" -s "Subject" mail.to@host.com < file_contents
using varibles from command line
#!/bin/sh
# Example script to copy files to different hosts
# Assumes same user is on all other servers
if [ $# -lt 1 ]; then
echo "\nUsage: script file [newfile]\n"
exit 1
fi
file=$1
echo $file | grep -q '^/'
if [ $? -ne 0 ]; then
file=$PWD/$file
fi
if [ $# -gt 1 ]; then
newfile=$2
else
newfile=$file
fi
thishost=`uname -n`
user=`id -un`
hostlist="host1 host2"
if [ ! -f $file ]; then
echo "\nCannot copy $file (doesn't exist?)\n"
exit 1
fi
# Copy the file to all the (other) hosts
echo Copying $file to $newfile
for host in $hostlist; do
if [ $host != $thishost ]; then
echo "Copying to $host:"
scp $file ${user}@$host:$newfile
fi
done
No comments:
Post a comment