RHEL Bash脚本用于R闪亮发布

RHEL Bash脚本用于R闪亮发布,r,linux,bash,rhel,R,Linux,Bash,Rhel,我正在尝试制作一个bash脚本,该脚本将自动执行命令,以便在R服务器上发布一些内容 以root用户身份登录时,我逐行输入以下内容: cd /opt/shiny-server/samples/sample-apps rm -R -f existingDirectory4Application cd /home/Username mv Directory4ApplicationNew /opt/shiny-server/samples/sample-apps cd /opt/shiny-server

我正在尝试制作一个bash脚本,该脚本将自动执行命令,以便在R服务器上发布一些内容

以root用户身份登录时,我逐行输入以下内容:

cd /opt/shiny-server/samples/sample-apps
rm -R -f existingDirectory4Application
cd /home/Username
mv Directory4ApplicationNew /opt/shiny-server/samples/sample-apps
cd /opt/shiny-server/samples/sample-apps
chmod -R 777 NewDirectory4Application
systemctl restart shiny-server
为了便于发布,我将目录命名为相同的名称;比如shinyApp

到目前为止,这是我的脚本,但我不断得到错误。我希望能够将包含要发布的应用程序文件的目录的参数传递给脚本:

#!/bin/bash

dashboard=$1
cd /opt/shiny-server/samples/sample-apps
rm -R -f $dashboard
cd /home/Username
mv $dashboard /opt/shiny-server/samples/sample-apps
cd /opt/shiny-server/samples/sample-apps
chmod -R 777 $dashboard
systemctl restart shiny-server
echo "Server has been restarted and Dashboard is now Published"
我得到的错误如下:

sh PubExisting.sh shinyApp
PubExisting.sh:第2行:$“\r”:未找到命令
:没有此类文件或目录/opt/shinny server/samples/sample apps
:没有这样的文件或目录/home/Username
mv:无法统计'shinyApp\r':没有这样的文件或目录
:没有此类文件或目录/opt/shinny server/samples/sample apps
chmod:无法访问'shinyApp\r\r':没有这样的文件或目录
无法重新启动服务器\x0d。服务:找不到单元。

服务器已重新启动,仪表板现在已发布
看起来您是从DOS编辑器编写脚本的,该编辑器具有Unix/Linux machien不喜欢的CRLF结尾。通过运行
dos2unix PubExisting.sh来清理它
dos2unix出现错误“command not found”。不过我确实是在记事本中创建的,只是将扩展名改为.sh,然后使用WinSCP将其传输到服务器。