Scripts imported from UNIX to Linux are not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripts imported from UNIX to Linux are not working
# 1  
Old 06-30-2016
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..

Code:
#############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 ############



Moderator's Comments:
Mod Comment Please use code tags as required by forum rules!

Last edited by RudiC; 06-30-2016 at 07:12 AM.. Reason: Added code tags & moved to an appropriate forum.
# 2  
Old 06-30-2016
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 Image

To reply you have a few options. You can click on the 'Post Reply' button Image 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
# 3  
Old 06-30-2016
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...
# 4  
Old 06-30-2016
Quote:
Originally Posted by laxman_bly
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.
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
# 5  
Old 06-30-2016
@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
# 6  
Old 06-30-2016
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 echoes but one, don't redirect it, and post what happens.
# 7  
Old 07-13-2016
@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..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Alternate of UNIX scripts in Linux

Hai All, Greetings.... I am doing a migration from Solaris to Linux .There are few scripts (logadm, nfsfind, gsscred_clean, kprop_script) for which I need a alternate in Linux. If somebody can help. Thanks in advance (1 Reply)
Discussion started by: Dilipkumarkm
1 Replies

2. Shell Programming and Scripting

Shell scripts migration from HP-Unix 11 to Red Hat Linux

We are changing our OS from HP-Unix 11 to Linux Red Hat. We have few k- shell, c - shell and sql scripts which are currently running under HP-Unix 11. Will these scripts work on LINUX as it is? or we need to do any code changes?IS there anyone who have done this kind of migration before?Thanks for... (2 Replies)
Discussion started by: Phoenix2
2 Replies

3. Linux

It is possible to find out when a particular encryption key was imported in linux

Hi All, In linux server some encryption keys were imported using gpg command. I want to know when those keys was imported. Is there any way to get when the encryption keys were imported? Thanks in advance.. :rolleyes: (1 Reply)
Discussion started by: latika
1 Replies

4. Shell Programming and Scripting

cron job is not working for two scripts

Hi Gurus, I have a test unix server in which currently some unix cronjob are running. I have written two script one is a shell script in which env variable are there (in that i am exporting those variables). I have also written a perl script . when i am running at the shell manually like... (5 Replies)
Discussion started by: sanjay.login
5 Replies

5. Shell Programming and Scripting

Linux - scripts not working in cron

hi all, i have scripts executable in manully, but not working in cron. any ideas? thanks a lot? * * * * * /home/dir/dir/file.sh #! /bin/sh alarmPath="/home/dir/monitoringAlarm" alarmDateTime="$(date +%Y%m%d) $(date +%H%M%S)" tomcatPID=`pidof /usr/local/jdk1.6.0_13/bin/java` echo "tomcat... (3 Replies)
Discussion started by: maxlee24
3 Replies

6. Red Hat

Linux - scripts not working in cron

hi all, i have scripts executable in manully, but not working in cron. any ideas? thanks a lot? * * * * * /home/dir/dir/file.sh #! /bin/sh alarmPath="/home/dir/monitoringAlarm" alarmDateTime="$(date +%Y%m%d) $(date +%H%M%S)" tomcatPID=`pidof /usr/local/jdk1.6.0_13/bin/java` echo "tomcat... (1 Reply)
Discussion started by: maxlee24
1 Replies

7. UNIX for Dummies Questions & Answers

alias not working in scripts

Hi All, PF below details, > cat run.sh #!/usr/bin/ksh alias ll="ls -l" > ./run.sh > ll ksh: ll: not found. Pls help on this? Thanks in Advance, Naga :cool: (2 Replies)
Discussion started by: Nagapandi
2 Replies

8. UNIX for Dummies Questions & Answers

Unix/Linux Scripts questions

Hi All, You have a very large file, named 'ColCheckMe', tab-delimited, that you are asked to process. You are told that each line in 'ColCheckMe' has 7 columns, and that the values in the 5th column are integers. Using shell functions (and standard LINUX/UNIX filters), indicate how you would... (7 Replies)
Discussion started by: am2007
7 Replies

9. UNIX for Dummies Questions & Answers

pulling scripts from unix to linux

:confused: I am working on transferring "good" running code scripts from unix to linux (suse). Some errors show in linux that are not present in unix. Specifically, the error code is: codename : no closing quote This is referring to the last line of the code + one line. I have used temporary... (3 Replies)
Discussion started by: pjconfig
3 Replies
Login or Register to Ask a Question