英文:
pg_restore command is not accepting filename as variable
问题
$latest = 'filename.sql'
kubectl exec -n testnamspace pod/test-- sh -c 'PGPASSWORD=ss pg_restore --clean -h postgresql -p 5432 -U test_user -d dbName -F c /tmp/$latest';
这是在读取 dbName 文件时出现的错误:
pg_restore: error: could not open input file "$/tmp/": No such file or directory
当我尝试回显 $latest 时,它可以工作,但在 pg_restore 命令中不起作用。对此有任何帮助将不胜感激。
英文:
$latest = 'filename.sql'
kubectl exec -n testnamspace pod/test-- sh -c 'PGPASSWORD=ss pg_restore --clean -h postgresql -p 5432 -U test_user -d dbName -F c /tmp/$latest'
This is the error I am getting while reading dbName file:
> pg_restore: error: could not open input file "$/tmp/": No such file or
> directory
When I try to echo $latest, it is working but not with pg_restore command. Any help in this regard would be appreciated
答案1
得分: 1
try using double quotes
kubectl exec -n testnamspace pod/test -- sh -c "PGPASSWORD=ss pg_restore --clean -h postgresql -p 5432 -U test_user -d dbName -F c /tmp/$latest"
or
latest='filename.sql'
command="PGPASSWORD=ss pg_restore --clean -h postgresql -p 5432 -U test_user -d dbName -F c /tmp/$latest"
kubectl exec -n testnamspace pod/test -- sh -c "$command"
英文:
try using double quotes
kubectl exec -n testnamspace pod/test -- sh -c "PGPASSWORD=ss pg_restore --clean -h postgresql -p 5432 -U test_user -d dbName -F c /tmp/$latest"
or
latest='filename.sql'
command="PGPASSWORD=ss pg_restore --clean -h postgresql -p 5432 -U test_user -d dbName -F c /tmp/$latest"
kubectl exec -n testnamspace pod/test -- sh -c "$command"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论