简体   繁体   中英

KornShell (ksh) redirection

I have a script which redirects std out/std err as below:

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

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. I am able to execute it via ksh /test/sched/test.ksh though.

Can someone help me with these. Thanks in advance.

I'm almost certain that the problem is because of DOS/Windows line endings

The error message you are getting is overwriting itself because of a carriage return. You can fix your file using 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? Are you certain?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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