0

This is a input file file1.txt:

premon D0000070 0x201 0x40

this is the script. script.sh

#!/bin/bash
CommandFileName=$1
while read line # This will read a line from file1.txt
 do
   FileName="${line// /_}"
   echo $FileName

   cmviewer -- -u USUPPXY-0 -b --agent=DCHUP --buffer-size=250000  #this will hold a buffer of size 2.5MB
   sleep 1

   cmviewer -- -u USUPPXY-0 -m --agent=DCHUP # this will start monitoring 
   sleep 1

   cmviewer -- -u USUPPXY-0 --up '$line' --agent=DCHUP  

   #this is the filtering condition // this should be replicate as  a command ->     cmviewer -- -u USUPPXY-0 --up 'premon D0000070 0x201 0x40'  #here I suspect $line is taking \n char aswell, so the command is not giving the desire output. #am I correct $line is taking new line char ? if it is so then how to remove it. 

   cmviewer -- -u USUPPXY-0 -s --agent=DCHUP #this will stop monitoring
   sleep 1

   cmviewer -- -u USUPPXY-0 -g --agent=DCHUP --dir=/root/  
   # this will collect the logs in /root directory.  - here I am getting “Parsing error  , premon D0000070 0x201 0x40 is not valid error” # but when I  execute the same command with out using script , it is working fine

   #mv /root/*.BIN /root/$FileName
   done < $CommandFileName

hope my question is clear..

4

2 回答 2

0

实际上你的问题不是很清楚......但尝试删除行尾的分号

done < $CommandFileName;

我不认为它应该在那里。^

于 2012-12-13T10:35:38.590 回答
0

很难确定您的问题是什么,但我相信您正试图cmviewer从输入文件中获取要传递的参数。尝试:

while read args; do
...
cmviewer -- -u USUPPXY-0 --up $args --agent=DCHUP
...
done < $CommandFileName

也就是说,只需在将参数传递给cmviewer. 或者您可能希望将所有参数作为单个参数传递给cmviewer,在这种情况下,您必须使用双引号:

cmviewer -- -u USUPPXY-0 --up "$args" --agent=DCHUP
于 2012-12-13T19:11:01.343 回答