0

This seems to be a simple issue but, I'm not able to figure it out. I am trying to run a couple of small scripts on a server and i'm having issues with that. i have an allhosts file that has the list of servers which is in the same location as that of the .sh file.

script to create a directory structure across all the 20 servers with 777 permissions

#!bin/bash
for q in `cat allhosts`
do
ssh $q "mkdir -p /opt/acd/hgf/tom/hanks/"
chmod -R 777 $q "/opt/acd/hgf/tom/hanks/" >/dev/null 2>&1
done

in the above script, it is only creating the directory paths and not changing the permissions for that path. I tried running that chmod command in a separate script, but no use..

script to scp the contents of hanks to the hanks folder created in the new server.

#!bin/bash
for q in `cat allhosts`
do
scp /opt/acd/hgf/tom/hanks/* $q:/opt/acd/hgf/tom/hanks/ >/dev/null 2>&1
done

in this script too, when i run it, its not copying anything to any of the servers.

i know this is a very small issue, but please check and let me know where I am going wrong. thanks in advance..

4

1 回答 1

0

第一个脚本失败,因为它chmod在本地机器上运行。您应该通过以下方式在远程计算机上运行它ssh- 您可以将其与其他ssh调用结合起来,如下所示:

ssh $q "mkdir -p /opt/acd/hgf/tom/hanks/ ; chmod -R 777 /opt/acd/hgf/tom/hanks/"

我猜第二个脚本失败了,因为第一个脚本没有设置权限;看起来不错。

于 2013-11-02T23:30:17.590 回答