一个csh脚本调用了若干个.sql脚本,但并非所有脚本都会被调用

编程语言 2026-07-09

我有一个csh脚本,用来在SQLPLUS中运行多个.sql脚本。

它确实在运行某些脚本,但并非全部。

这些脚本在SQLPLUS中单独执行时都能按预期工作,因此我知道问题不在脚本本身。

这是我的csh脚本:

 #!/bin/csh -f
 set pw = [password]
 sqlplus -s /nolog << EOF
 connect [username]/${pw}
 @ /path/to/script/script1.sql input1 input2
 @ /path/to/script/script2.sql input1 input2
 @ /path/to/script/script3.sql input1 input2
 @ /path/to/script/script4.sql input1 input2
 @ /path/to/script/script5.sql input1 input2
 @ /path/to/script/script6.sql input1 input2
 EOF

当我运行这个csh脚本时,脚本1、3、5和 6的输出文件被创建。脚本2 和4 仿佛根本没有执行。它们没有产生任何输出,也没有出现在标准输出日志中。

补充: 更奇怪的是,如果把脚本1、3、5和 6注释掉,脚本2 和4 才能运行。

有什么想法为什么会这样,以及如何修复?

我是在Solaris 11.4上运行。

解决方案

I tried Reactive Firewall's suggestion above, which was to connect to sqlplus independently for each command. This has solved the problem:

 #!/bin/csh -f
 set pw = [password]

 sqlplus -s /nolog << EOF
 connect [username]/${pw}
 @ /path/to/script/script1.sql input1 input2
EOF

 sqlplus -s /nolog << EOF
 connect [username]/${pw}
 @ /path/to/script/script2.sql input1 input2
EOF

 sqlplus -s /nolog << EOF
 connect [username]/${pw}
 @ /path/to/script/script3.sql input1 input2
EOF

 sqlplus -s /nolog << EOF
 connect [username]/${pw}
 @ /path/to/script/script4.sql input1 input2
EOF

 sqlplus -s /nolog << EOF
 connect [username]/${pw}
 @ /path/to/script/script5.sql input1 input2
EOF

 sqlplus -s /nolog << EOF
 connect [username]/${pw}
 @ /path/to/script/script6.sql input1 input2
 EOF
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章