脚本中多个参数就无法执行?
- slysmart
- 帖子: 7
- 注册时间: 2024-05-24 13:00
- 系统: 22.04
脚本中多个参数就无法执行?
OUT_SQL =“/home/abc/backup/”$(date +"%Y%m%d").dump
pg_dump -h localhost -U postgres -d test -F c -b -f $OUT_SQL --这句执行没问题
----------------------------------
DB_USER="postgres "
DB_NAME="test"
OUT_SQL =“/home/abc/backup/”$(date +"%Y%m%d").dump
pg_dump -h localhost -U $DB_USER -d DE_NAME -F c -b -f $OUT_SQL
执行”pg_dump: error: connection to at "localhost"“
pg_dump -h localhost -U postgres -d test -F c -b -f $OUT_SQL --这句执行没问题
----------------------------------
DB_USER="postgres "
DB_NAME="test"
OUT_SQL =“/home/abc/backup/”$(date +"%Y%m%d").dump
pg_dump -h localhost -U $DB_USER -d DE_NAME -F c -b -f $OUT_SQL
执行”pg_dump: error: connection to at "localhost"“
- qy117121
- 论坛版主
- 帖子: 50559
- 注册时间: 2007-12-14 13:40
- 系统: Winbuntu
- 来自: 志虚国乌由市
- 联系:
Re: 脚本中多个参数就无法执行?
你下面数据库名称那里错了啊
- slysmart
- 帖子: 7
- 注册时间: 2024-05-24 13:00
- 系统: 22.04
Re: 脚本中多个参数就无法执行?
没有错,但就是用参数形式无法执行
- slysmart
- 帖子: 7
- 注册时间: 2024-05-24 13:00
- 系统: 22.04
Re: 脚本中多个参数就无法执行?
只是用户名和数据库名变成形参就无法执行了
- astolia
- 论坛版主
- 帖子: 6569
- 注册时间: 2008-09-18 13:11
Re: 脚本中多个参数就无法执行?
你再好好看看?
还有一处没法用颜色标记的地方:DB_USER赋值的时候引号里多加了一个空格
等于是你用户名和数据库名全部没有设置对就去连接了
- lilydjwg
- 论坛版主
- 帖子: 4252
- 注册时间: 2009-04-11 23:46
- 系统: Arch Linux
- 联系:
Re: 脚本中多个参数就无法执行?
说句题外话:竟然有人专门用 localhost 连接 postgresql 数据库。
另外 postgresql 用户名不支持空格的吧?
另外 postgresql 用户名不支持空格的吧?
- slysmart
- 帖子: 7
- 注册时间: 2024-05-24 13:00
- 系统: 22.04
Re: 脚本中多个参数就无法执行?
- astolia
- 论坛版主
- 帖子: 6569
- 注册时间: 2008-09-18 13:11
- slysmart
- 帖子: 7
- 注册时间: 2024-05-24 13:00
- 系统: 22.04
Re: 脚本中多个参数就无法执行?
,错误见截图
,shell脚本
- astolia
- 论坛版主
- 帖子: 6569
- 注册时间: 2008-09-18 13:11
Re: 脚本中多个参数就无法执行?
检查一下这段脚本的换行是不是dos/win风格,即回车符+换行符。
如果是的话,去掉回车符将其转换成unix风格。可以用dos2unix,或者用sed -i 's/\r//' xxx.sh
如果是的话,去掉回车符将其转换成unix风格。可以用dos2unix,或者用sed -i 's/\r//' xxx.sh
- slysmart
- 帖子: 7
- 注册时间: 2024-05-24 13:00
- 系统: 22.04
- slysmart
- 帖子: 7
- 注册时间: 2024-05-24 13:00
- 系统: 22.04
- astolia
- 论坛版主
- 帖子: 6569
- 注册时间: 2008-09-18 13:11