简体   繁体   English

nmon上的基本bash shell脚本

[英]Basic bash shell scripting on nmon

I'm having a problem trying to run nmon using my own script where nmon is deployed in the linux environment. 我在尝试使用自己的脚本(在Linux环境中部署nmon)运行nmon时遇到问题。

Based on this script, I am required to execute command "test.sh 2 5", with variables represented by value 2 and 5 基于此脚本,我需要执行命令“ test.sh 2 5”,其变量由值2和5表示

#!/bin/bash
#sh test.sh variable1 variable2
./nmon -f -s$1 -c $2
total=$(( $1 * $2 ))
echo "------------------------------------------------"
echo -e "Providing $2 snapshots with interval of $1s"
echo -e "Saving into $HOSTNAME. Completing in $total seconds\n\n"

However, I am receiving the following output: 但是,我收到以下输出:

[osmusr@bssosmappv4001 ~]$ sh nmonscript2.sh 2 4
------------------------------------------------
Providing 4 snapshots with interval of 2s
 secondsnto bssosmappv4001. Completing in 8

May I know which part did I missed out? 我可以知道错过了哪一部分吗? Why is it not displaying the output correctly? 为什么不能正确显示输出?

total has a carriage return ( 0x0D / \\r / ^M ) after it. total后面有一个回车符( 0x0D / \\r / ^M )。 Most likely the script has windows line endings ( \\r\\n ), and the \\r is getting tacked onto the total assignment. 该脚本很可能具有Windows行尾( \\r\\n ),并且\\r正在添加到总分配中。 Run the file through dos2unix . 通过dos2unix运行文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM