我在尝试执行脚本时收到此错误
max,max: bad port number-- sftp://11.111.10.3
usage: -i host-name [port]
?Invalid command
Not connected.
Not connected.
Not connected.
这个脚本应该检查10个服务器的CPU内存和磁盘使用情况,我在一台服务器上运行它并且必须ftp并检查其他服务器并将所需数据存储在一台服务器上,但这个错误不会消失
#! /bin/bash
BasePath=$(cd `dirname $0`; pwd)
function FtpMonitFile(){
ServerPath=${BasePath}/data/$5
mkdir -p $ServerPath
ftp -i $2,$3 sftp://$1 <<EOF
set xfer:clobber on
cd $ServerPath
cd $4
get Monitor_$(date +%Y%m%d).txt
bye
EOF
}
function GenerateReport(){
mkdir -p ${BasePath}/result
if [ ! -f ${BasePath}/result/$1.txt ]; then
echo "Time|" > ${BasePath}/result/$1.txt
awk 'BEGIN{
for(i=0;i<=24;i++)
{
for(j=0;j<60;j=j+10)
{
if(length(i)<2){i="0"i}
if(length(j)<2){j="0"j}
print i ":" j "|"
}
}
}' >> ${BasePath}/result/$1.txt
fi
awk -v DayFile="${BasePath}/data/$1/Monitor_$(date +%Y%m%d).txt" -v ReFile="${BasePath}/result/$1.txt" -v Day=$(date +%m%d) 'BEGIN{
while(getline<DayFile){
if($2>flag[substr($1,1,4)]){
flag[substr($1,1,4)]=$2;
}
}
}{
if(substr($1,1,4)=="Time"){
print $0 Day "|";
}else{
print $0 flag[substr($1,1,4)] "|";
}
}' ${BasePath}/result/$1.txt >${BasePath}/result/$1.tmp
mv ${BasePath}/result/$1.tmp ${BasePath}/result/$1.txt
}
function main(){
if [ ! $# == 5 ]; then
echo "Please check the parameters"
exit
fi
FtpMonitFile $1 $2 $3 $4 $5
GenerateReport $5
}
#param: ip user_name password remote_dir server_name()
#e.g.
# FtpMonitFile 10.130.27.2 soft soft /home/soft/cwk OCS2
#FtpMonitFile 10.130.27.1 soft soft /home/soft/cwk OCS1
main 11.111.10.3 max max /home/max/ocsrpt/cwk server1
main 11.111.10.3 max max /home/max/ocsrpt/cwk server2
错误在第8行,第8行的代码是
ftp -i $2,$3 sftp://$1 <<EOF
我尝试使用以下代码
sftp://&1:22
或sftp://&1":"22
但我仍然得到同样的错误,关于我如何能够帮助的任何建议!!
答案 0 :(得分:0)
我将stfp更改为ftp并运行
x <- matrix(1:25, 5,5)
> diag(x)
> n <- function(x){
y <- min(dim(x))
c <- vector()
for(i in 1:y){
c[i] <- x[i,i]
}
c
}
> n(x)
感谢