シェルスクリプトの問題:\ rが文字として解釈されました

シェルスクリプトの問題:\ rが文字として解釈されました

新しいNASサーバーに独自のクラウドを作成しようとしていますが、使用しているスクリプトは機能しません。

スクリプト:

#!/bin/bash

chown -R http:http /volume1/web/owncloud/
chown -R http:http /volume1/web/owncloud/apps/
chown -R http:http /volume1/web/owncloud/config/
chown -R http:http /volume1/web/owncloud/themes/
chown -R http:http /volume1/owncloud/

chown http:http /volume1/web/owncloud/.htaccess

find /volume1/web/owncloud/ -type f -print0 | xargs -0 chmod 777

find /volume1/web/owncloud/ -type d -print0 | xargs -0 chmod 777
find /volume1/owncloud/ -type d -print0 | xargs -0 chmod 777

chmod 777 /volume1/web/owncloud/.htaccess

答えは次のとおりです。

Yamakhalah@Jarvis:/$ sudo -su root
Password:
sh-4.3# cd /
sh-4.3# sh /volume1/web/scripts/perm_upd.sh
/volume1/web/scripts/perm_upd.sh: line 2: $'\r': command not found
chown: cannot access ‘/volume1/web/owncloud/\r’: No such file or directory
chown: cannot access ‘/volume1/web/owncloud/apps/\r’: No such file or directory
chown: cannot access ‘/volume1/web/owncloud/config/\r’: No such file or directory
chown: cannot access ‘/volume1/web/owncloud/themes/\r’: No such file or directory
chown: cannot access ‘/volume1/owncloud/\r’: No such file or directory
/volume1/web/scripts/perm_upd.sh: line 8: $'\r': command not found
chown: cannot access ‘/volume1/web/owncloud/.htaccess\r’: No such file or directory
/volume1/web/scripts/perm_upd.sh: line 10: $'\r': command not found
chmod: invalid mode: ‘777\r’
Try 'chmod --help' for more information.
chmod: invalid mode: ‘777\r’
Try 'chmod --help' for more information.
chmod: invalid mode: ‘777\r’
Try 'chmod --help' for more information.
chmod: invalid mode: ‘777\r’
Try 'chmod --help' for more information.
chmod: invalid mode: ‘777\r’
Try 'chmod --help' for more information.
chmod: invalid mode: ‘777\r’
Try 'chmod --help' for more information.
/volume1/web/scripts/perm_upd.sh: line 12: $'\r': command not found
chmod: invalid mode: ‘777\r’
Try 'chmod --help' for more information.
chmod: invalid mode: ‘777\r’
Try 'chmod --help' for more information.
/volume1/web/scripts/perm_upd.sh: line 15: $'\r': command not found
sh-4.3#

なぜこれがどこに起こるのか説明できますか\r

ベストアンサー1

Windowsスタイルファイルを使用してNASにコピーしている可能性があります。 Unixスタイルに変換する必要があります。詳細はWikipediaリンク。一部の編集者はファイルを別の形式で保存できます。編集者がこれを実行できない場合は、dos2unixほとんどのLinuxディストリビューションで利用可能なユーティリティを使用できます。

上記のオプションのいずれも役に立たない場合、このスタックはオーバーフローします。たぶんそれはあなたに役立つかもしれません。

おすすめ記事