[英]Bash Shell script in unix to rsh to another machine and perform command
Im trying to write a script that rsh's over to a unix machine and executes certain commands on certain files 我正在尝试编写一个将rsh移到unix机器上并在某些文件上执行某些命令的脚本
SCRIPT SO FAR: 脚本这么远:
#!/bin/bash
#
MACHINE=uk01ff200
DIRECTORY=/var/core
rsh $MACHINE "cd /var/core"
for file in `ls -1 core.*`
do stack_dump $file
done
When I do this manually in the shell on the command line it works. 当我在命令行中的Shell中手动执行此操作时,它将起作用。 So if I rsh over to the machine, cd to the directory, then type in the for loop it works (so I know the for loop syntax is correct). 因此,如果我将rsh转到计算机,将cd转到目录,然后键入for循环,则它可以正常工作(因此我知道for循环语法是正确的)。 So I dont know where I'm going wrong with my script. 所以我不知道我的脚本哪里出了问题。
What I would do using a here-document : 我将使用here-document做些什么:
#!/bin/bash
#
MACHINE=uk01ff200
DIRECTORY=/var/core
rsh $MACHINE bash <<'EOF'
cd /var/core
for file in core.*
do stack_dump "$file"
done
EOF
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.