简体   繁体   English

KornShell(ksh)重定向

[英]KornShell (ksh) redirection

I have a script which redirects std out/std err as below: 我有一个脚本重定向std out / std err,如下所示:

SCRIPTS=/test/scripts
LOG=/test/log
echo $SCRIPTS
echo $LOG
$SCRIPTS/dmm_algo_ofac_daily_sched.ksh >> $LOG/test12.log 2>&1

This script is not able to expand $SCRIPTS and $LOG 此脚本无法扩展$SCRIPTS$LOG

If I replace it as below: 如果我将其替换如下:

/test/scripts/daily_sched.ksh >> /test/log/test12.log 2>&1

It complains as below: 它抱怨如下:

: bad file unit numberd/test.ksh: line 33: 1

Also I am not able to invoke the script from the directory where it is saved. 此外,我无法从保存它的目录中调用脚本。 If I do 如果我做

./test.ksh it gives me error saying file not found. ./test.ksh它给我错误说找不到文件。 I am able to execute it via ksh /test/sched/test.ksh though. 我可以通过ksh /test/sched/test.ksh执行它。

Can someone help me with these. 有人可以帮助我这些。 Thanks in advance. 提前致谢。

I'm almost certain that the problem is because of DOS/Windows line endings 我几乎可以肯定问题是因为DOS / Windows行结尾

The error message you are getting is overwriting itself because of a carriage return. 您收到的错误消息是由于回车而覆盖自身。 You can fix your file using dos2unix . 您可以使用dos2unix修复文件。

将magic #!/bin/ksh添加到第一行以直接调用,而无需在命令行上命名解释器。

I'll conjecture wildly that your root cause(s) has (have) nothing to do with redirection. 我会疯狂地推测你的根本原因与重定向无关。

Is the script you've exhibited /test/sched/test.ksh or /test/scripts/test.ksh? 您展示的脚本是/test/sched/test.ksh还是/test/scripts/test.ksh? Are you certain? 你确定吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM