我的线路有点问题。我尝试连接两个字符串。如果我用@Client.ip这样做,我会得到一个带有新行的字符串。@Client.ip是一个字符串。
我使用了这个:
order= "net rpc shutdown #{ip} --user=administrator%***! --timeout=100 --force -C 'bla'"或者这个
order= "net rpc shutdown "+ @client.ip + " --user=administrator%*** --timeout=100 --force -C 'bla'"结果是这样的:
net rpc shutdown 178.213.111.69
--user=administrator%*** --timeout=100 --force -C 'bla'如果我手动编写ip,然后将其连接起来,它工作得很好,一切都在一行中……为什么会发生这种情况?有人知道吗?:-)我需要在一行中使用这个字符串才能使用系统(-)命令。
发布于 2012-07-23 23:19:38
听起来好像@client.ip在它的末尾有一个换行符。试着把它去掉
order= "net rpc shutdown #{@client.ip.rstrip} --user=administrator%*** --timeout=100 --force -C 'bla'"String#rstrip将删除字符串末尾的所有空格。
https://stackoverflow.com/questions/11615390
复制相似问题