ssh は Unix pwd コマンドの出力をローカルサーバ上のファイルにリダイレクトします。

ssh は Unix pwd コマンドの出力をローカルサーバ上のファイルにリダイレクトします。

abcd.shスクリプト:

####
ssh $user_name@$ftp_site pwd > /export/home/appwxsms/remotepathfile.lst;
pathofremote =`sed -n '1p' $HOME/remotepathfile.lst`
export  pathofremote
#####

abcd.shを実行します。

-bash:./abcd.sh
 pathofremote: command not found

remotepathfile.lst > output.txt
-bash: /export/home/appwxsms/remotepathfile1.lst: Permission denied

abcd.shスクリプトを実行すると、ローカルパスremotepathfile.lstで生成されたファイルの出力を変数に送信できません。pathofremote

また、ファイル出力をローカルサーバー上の他のファイルに保存することはできません。

ベストアンサー1

変数の割り当ての構文エラーにもかかわらず、ファイルは希望の方法で満たされ続けます。

foo =bar     # This will attempt to run the command 'foo' with the parameter '=bar'
foo=bar      # This will set the variable 'foo' equal to 'bar'
foo="$(bar)" # This will set the variable 'foo' to the output of the execution of 'bar'

おすすめ記事