Remote execution of command to find available space logging in ftp mode.
i have the below program to connect to remote unix box and to find the space on the other machine being at the ftp prompt.
i dont want to use ssh, etc apart from this approach. can any1 help me out in this regard? `ls -ld /app | awk '{ print $5; }' > percent.txt` the above command is working fine but how to find the exact space utilized in that particular directory? Coz i cannot use df -k command at ftp prompt. if i use ! mark !df -k it gives the current box space and not the space of the box where i am connected to with ftp #!/bin/sh filesystems="/app" export INDIR=/app/ FTP_HOST1=ABCDEF1 FTP_HOST2=ABCDEF2 FTP_HOST3=ABCDEF3 FTP_HOST4=ABCDEF4 FTP_HOST5=ABCDEF11 FTP_HOST6=ABCDEF7701 FTP_HOST7=ABCDEF7702 FTP_HOST8=ABCDEF7709 FTP_HOST9=ABCDEF7710 FTP_HOST10=ABCDEF7713 FTP_HOST11=ABCDEF7714 FTP_HOST12=ABCDEF7716 FTP_HOST13=ABCDEF7718 FTP_USER_NAME=ftp FTP_PASSWD=xfffffx echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF1 open $FTP_HOST1 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF1 while read line do if [ $line -ge 12288 ] then echo "Disk space very low for $FTP_HOST1" > dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF2 open $FTP_HOST2 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF2 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST2" >> dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF3 open $FTP_HOST3 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF3 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST3" >> dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF4 open $FTP_HOST4 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF4 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST4" >> dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF5 open $FTP_HOST5 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF5 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST5" >> dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF6 open $FTP_HOST6 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF6 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST6" >> dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF7 open $FTP_HOST7 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF7 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST7" >> dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF8 open $FTP_HOST8 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF8 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST8" >> dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF9 open $FTP_HOST9 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF9 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST9" >> dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF10 open $FTP_HOST10 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF10 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST10" >> dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF11 open $FTP_HOST11 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF11 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST11" >> dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF12 open $FTP_HOST12 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF12 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST12" >> dsreport.txt fi done < percent.txt echo -e "\n=>\n=><$i>Checking for production box Disk Space\n=>" ftp -vin <<EOF13 open $FTP_HOST13 user $FTP_USER_NAME $FTP_PASSWD lcd /app `ls -ld /app | awk '{ print $5; }' > percent.txt` bye EOF13 while read line do if [ $line -ge 12288 ] then echo "Disk space very low $FTP_HOST13" >> dsreport.tx fi done < percent.txt |
If you use the utility 'expect', it will make your life WAY easier. That utility should come with a script called autoexpect. Once you have it, just run the 'autoexpect' command and issue the commands that you wish to use. Once that is done, type 'exit'. That will drop you out of the script creation and write the file... it defaults to script.exp. Once that is done, edit the file to accept positional variables.
Here's an example: Code:
set force_conservative 0 ;# set to 1 to force conservative mode even if Code:
|
y we want to log in FTP mode is that. this script runs on production unix boxes. and we dont have permissions to login as anonymous user etc.... so found this approach to find the disk space (dont know this works r not). all the unix boxes are having weblogic instanes running. as the weblogic logs pile up, the disk space minimizes to ZERO, which results in PROD weblogic instance to go down. to avoid that we want to define a crontab job which runs every one hr on the prod boxes to check the disk space. and that too the script should run only from one of the PROD box and log into other PROD boxes and if the disk space is more than 90% should send an email to the concerned people
|
Quote:
|
All times are GMT -5. The time now is 02:17 AM. |