我执行shell脚本时如何检索以下错误


-1

我有一个脚本登录到远程服务器。但我试图执行脚本发生一些错误。

日志:

我的剧本:

#!/bin/bash
S1=$(ssh -t selvam-odc-shell1 "users | wc -w ")
S2=$(ssh -t selvam-odc-shell2 "users | wc -w ")
S3=$(ssh -t selvam-odc-shell3 "users | wc -w ")
if [ "$S1" -le 100 ];
then 
ssh -t  selvam-odc-shell1 " bash"
if [ "$S2" -le 100 ];
then 
ssh -t  selvam-odc-shell2 "bash"
elif [ "$S3" -le 100 ]; 
then
ssh -t  selvam-odc-shell3 "bash"
else
echo " Shell has been more than 100 users.Please try again later
fi

但是o / p

[user@selvam-odc-sunray2: ~]#./shell.sh
Connection to selvam-odc-shell1 closed.
Connection to selvam-odc-shell2 closed.
Connection to selvam-odc-shell3 closed.
: integer expression expected60
: integer expression expected 29

请帮我解决这个问题。

谢谢 MM SELVAM


您是否尝试使用脚本打开3个shell?
LDC3

是的。最后我需要在一个shell中登录
Mariselvam

Answers:


0

ssh命令不仅添加了数字,还添加了换行符。 这意味着你的变量有这样的内容:“1 \ n”这不是一个整数。

删除引号: S1 = $(ssh -t selvam-odc-shell1用户| wc -w)


你能为上面提供正确的脚本吗?
Mariselvam
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.