Scripts imported from UNIX to Linux are not working

Hi,
Recently we migrated our app from Unix to Linux platform. All our shell scripts which use to work in Unix platform are not working in Linux now.
below is such sample script. I tried removing trailing spaces, but no luck. dear experts kindly help..

#############BEGIN###############
split -l 800 $1 RC
ls -lrt RC* | awk 'print $9}' |while read line
do
echo "SAS3" >upd_supp_service_lu_ws.txt
echo "55" >>upd_supp_service_lu_ws.txt
echo "SAS_ACTION LOGIN" >>upd_supp_service_lu_ws.txt
echo "LOGIN bss" >>upd_supp_service_lu_ws.txt
echo "PASSWORD client" >>upd_supp_service_lu_ws.txt
echo "\$END\$" >>upd_supp_service_lu_ws.txt
echo "\n" >>upd_supp_service_lu_ws.txt
cat $line |while read a b c d
#       AccNo AccName GrpName Orderno
do
echo "SAS3" >>upd_supp_service_lu_ws.txt
echo "00"  >>upd_supp_service_lu_ws.txt
echo "SAS_ACTION REQUEST" >>upd_supp_service_lu_ws.txt
echo "REQ_OBJ 11" >>upd_supp_service_lu_ws.txt
echo "REQ_TYPE 1" >>upd_supp_service_lu_ws.txt
echo "NE_TYPE GVPN" >> upd_supp_service_lu_ws.txt
echo "NE_ID ITSGVPN" >> upd_supp_service_lu_ws.txt
echo "ACCOUNT_NO $a" >>upd_supp_service_lu_ws.txt
echo "ACCOUNT_NAME $b" >>upd_supp_service_lu_ws.txt
echo "GRP_NUM $c">>upd_supp_service_lu_ws.txt
echo "GRP_NAME $c" >>upd_supp_service_lu_ws.txt
echo "REQ_USER ILINK">>upd_supp_service_lu_ws.txt
echo "RESP_QUEUE_ID NONE" >>upd_supp_service_lu_ws.txt
echo "ORDER_NO $d" >>upd_supp_service_lu_ws.txt
echo "\$END\$" >>upd_supp_service_lu_ws.txt
echo "\n" >>upd_supp_service_lu_ws.txt
done
echo "55" >>upd_supp_service_lu_ws.txt
echo "SAS_ACTION LOGOUT" >>upd_supp_service_lu_ws.txt
echo "\$END\$" >>upd_supp_service_lu_ws.txt
echo "\n" >>upd_supp_service_lu_ws.txt
cat upd_supp_service_lu_ws.txt | tcp_connect localhost 44200
done
############END ############

Hello and Welcome to The UNIX and Linux Forums!

Please read the our FAQ on how to post new threads in the forums.

As a registered user you can go to any forum where you have permission to post and create new threads, view threads and leave replies. You should always search the forums before posting a new thread (Google Site Search).

To create a new thread, click on a forum you would like to post in, for example, UNIX for Dummies Questions & Answers, and then click on the new thread icon

To reply you have a few options. You can click on the 'Post Reply' button and add a new post to the end of the thread. Alternatively, you can leave a quick reply in a quick editor box listed below the posts in the thread.

If you have further questions on forum operations, do not send email or private messages (PMs) to us. You are required to post these questions here:

Post Here to Contact Site Administrators and Moderators

Enjoy, Learn and Teach!

The UNIX and Linux Forums

WHAT exactly is "not working in Linux now"?

Except for a syntax error (missing "{" in the awk statement) that would fail on any platform I can't find any immediate need for action. Quite some potential for optimization, though.

Please post OS and shell version of both "Unix platform" and Linux.

EDIT: What does tcp_connect do? That might not be available on Linux...

From the "50 Tips for Better English":

Be more or less precise!

Seriously: Which Unix system? Which Linux platform? What scripts?

My suspicion is that your Unix system used a certain default system shell (depending on the Unix systems type and version this could be a Bourne shell, Korn Shell, or even C-shell) and your new Linux system uses a different shell (depending on the specific type a "dash" or a "bash" most likely). This might lead to problems.

Another reason why your scripts fail is that they have no sort of environment explicitly set. Maybe you had some sort of standard-enviroment set in your old Unix box which is different (or non-existent) in your new box.

I hope this helps.

bakunin

@RudiC: Sorry about that,
tcp_connect is stand alone program from appliction. it is available. i corrected syntax error "{". Still the issue exists
Issue is: when i run the script i see the error "line 37: syntax error: unexpected end of file"
Platform details are:
New: GNU/Linux 2.6.32-504.el6.x86_64, shell is /bin/bash
Old: Unix HP-UX B.11.31 U ia64, shell is /usr/bin/ksh

Sounds like a missing quote or a missing closing keyword somewhere, of which I can't find any in your sample.
Try running a skeleton script, remove all the echo es but one, don't redirect it, and post what happens.

@RudiC, I tried copy, paste each line by line.. then it works.
May be issue is with new line char, i am unsure! But i noticed one difference between HP-UX and Linux platforms. i.e., echo "\n" in unix (sh) prints new line but in Linux (ksh) echo "\n" prints \n as output.
Anyways, thanks for your suggestions it worked..

Actually this has nothing to do with your OS but everything with your shell. If i remember correctly HP-Ux uses a Korn shell as system default (not sure about that) and if this is the case then echo \n should indeed output "\n", as with the Linux ksh.

Use the print command instead of echo if you are working with the Korn shell.

I hope this helps.

bakunin