【发布时间】:2016-01-28 12:08:31
【问题描述】:
希望有人可以帮助我解决我试图在 CentOS 机器上运行的这个 bash 脚本。我在 FreeBSD 上写过这样的脚本
#!/bin/sh
setenv code1 "grant select on "
setenv code2 " to testusr"
echo setting read only access
foreach table (table1 table2 table3)
psql -c "psql -d databasename -c '$code1$table$code2'"
end
echo finished
然后我改为跟随但它不起作用。它抱怨倒数第三行 (sudo su postgres) 有人可以帮忙吗?
#!/bin/bash
set env code1 "grant select on "
set env code2 " to testusr"
echo setting read only access
for table in 'table1 table2 table3'
sudo su postgres -c "psql -d databasename -c '$code1$table$code2'"
do;
echo finished
任何帮助将不胜感激。
【问题讨论】:
-
你的问题到底是什么?
-
第一个脚本看起来像
csh,尽管有/bin/shshebang 行。
标签: bash postgresql shell centos