Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 878
sab Avatar asked Mar 21 '26 05:03

sab


1 Answers

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.

like image 113
Dennis Williamson Avatar answered Mar 24 '26 05:03

Dennis Williamson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!