LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-10-2013, 03:44 PM   #1
prashanth1414
LQ Newbie
 
Registered: Jun 2013
Posts: 10
Blog Entries: 1

Rep: Reputation: Disabled
KSH Scripts migration from Solaris to Linux


I have 14 KSH scripts which i need to migrate to Linux without modification,even though the standard scripting is bash.

Can someone help me how should i start and what can i do?

Thanks,
Prash.
 
Old 06-10-2013, 04:53 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
ksh is available for linux and probably part of the packages available for your distro, once you install it you should be good to go.

2 things do come to mind:
- any solaris specific commands that might be used need to be "translated" to a linux version/equivalent.
- there are more then one ksh versions available (ksh93 and pdksh), do check which one you need.
 
1 members found this post helpful.
Old 06-11-2013, 08:45 AM   #3
prashanth1414
LQ Newbie
 
Registered: Jun 2013
Posts: 10

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
I have pdksh.
For the migarion of scripts:I think i just need to copy and paste them to linux box.Am i right?
 
Old 06-11-2013, 09:08 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,685

Rep: Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971
Quote:
Originally Posted by prashanth1414 View Post
I have pdksh.
For the migarion of scripts:I think i just need to copy and paste them to linux box.Am i right?
That's 'step 1'. After that, you try to RUN THEM on the Linux system, and correct error(s) as found. That's how you migrate ANY program from one platform to another.

And as druuna said, any Solaris specific commands in those scripts won't work, so you'll have to figure out what the Linux equivalent is. Also, some commands may return different output, even though the commands are the same. Again, you'll have to just step through the files one at a time, and adjust things as needed.
 
1 members found this post helpful.
Old 06-11-2013, 09:24 AM   #5
prashanth1414
LQ Newbie
 
Registered: Jun 2013
Posts: 10

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
That's 'step 1'. After that, you try to RUN THEM on the Linux system, and correct error(s) as found. That's how you migrate ANY program from one platform to another.

And as druuna said, any Solaris specific commands in those scripts won't work, so you'll have to figure out what the Linux equivalent is. Also, some commands may return different output, even though the commands are the same. Again, you'll have to just step through the files one at a time, and adjust things as needed.
Thank you both For your help
 
Old 06-11-2013, 06:53 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Also, I would scp or ftp them.
Copy/paste from the terminal can add hard newlines to lines that display wrapped in normal display.
I'd also recommend using the proper ksh, not pdksh.
 
Old 06-12-2013, 08:45 AM   #7
prashanth1414
LQ Newbie
 
Registered: Jun 2013
Posts: 10

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
Also, I would scp or ftp them.
Copy/paste from the terminal can add hard newlines to lines that display wrapped in normal display.
I'd also recommend using the proper ksh, not pdksh.

So instead of using cp command to migrate do u suggest me to use scp command.
How can we execute or run the ksh scripts.
 
Old 06-12-2013, 10:19 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,685

Rep: Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971
Quote:
Originally Posted by prashanth1414 View Post
So instead of using cp command to migrate do u suggest me to use scp command.
Well, did you read the man pages on those commands?? Since you can't just cp (copy) a file from one machine to another, you will obviously have to use some sort of network copy (like scp), to move the scripts over. You can also put them on a thumbdrive, CD, DVD, or move them however you want.
Quote:
How can we execute or run the ksh scripts.
The same way you're running them now, obviously. They're just scripts...execute them.
 
Old 06-21-2013, 09:22 AM   #9
prashanth1414
LQ Newbie
 
Registered: Jun 2013
Posts: 10

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Hi im migrating unix scripts to linux.

I get this error when i run one of my scripts.Im using scp command to copy the script to the server.

ssh: connect to host SERVERNAME port 22: Connection refused
lost connection

pls help...
 
Old 06-21-2013, 09:56 AM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,685

Rep: Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971
Quote:
Originally Posted by prashanth1414 View Post
Hi im migrating unix scripts to linux.
Yes, we know that, since that's how you opened this thread.
Quote:
I get this error when i run one of my scripts.Im using scp command to copy the script to the server.

ssh: connect to host SERVERNAME port 22: Connection refused
lost connection

pls help...
Spell out your words, please. And do you get the error when you're trying to scp the script from one system to another, or do you get it when you EXECUTE the script on the Linux system??? And are you really putting "SERVERNAME" in the command, or are you actually using a valid hostname/IP address? What is the exact command you're running?
 
Old 06-21-2013, 03:58 PM   #11
prashanth1414
LQ Newbie
 
Registered: Jun 2013
Posts: 10

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Yes im using a valid hostname.
Running the script with scp command on linux
Execution command:./filename.ksh

Im using scp command in this script to copy it from my home directory to the hostserver.

scp -p my/dir username@hostserver:dest/dir
 
Old 06-22-2013, 02:16 AM   #12
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by prashanth1414 View Post
Yes im using a valid hostname.
Running the script with scp command on linux
Execution command:./filename.ksh

Im using scp command in this script to copy it from my home directory to the hostserver.

scp -p my/dir username@hostserver:dest/dir
TB0ne asked for the exact command that's being run and I doubt the bold part is it.

It might be a good idea (if at all possible) to post the script that's giving you problems so we can have a look.
 
Old 06-24-2013, 08:58 AM   #13
prashanth1414
LQ Newbie
 
Registered: Jun 2013
Posts: 10

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
#!/bin/ksh

RC=0
errmsg="`basename $0` `date +%y-%m-%d-%H-%M` return cd: $RC"

OWNER=PEND
export SCRIPTS_DIR=`dirname $0`
STELLANT_DIR=/source/directory
STELLANT_PARSER=/dest/dir/filename
STELLANT_SERVER=servername
scp -p $STELLANT_DIR/filename.dat username@$STELLANT_SERVER:$STELLANT_PARSER

rc=$?
if [[ $rc != 0 ]]; then
addtoerrmsg=" failed."
print $addtoerrmsg
RC=8
errmsg="$errmsg $addtoerrmsg"

else
print "xxx.dat move to $STELLANT_SERVER:$STELLANT_PARSER successful."
fi

# Send page if errors.

if [[ $RC > 0 ]]; then
$SCRIPTS_DIR/error.ksh $OWNER $errmsg
print "paging"
fi

exit $RC
 
Old 06-24-2013, 09:58 AM   #14
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,685

Rep: Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971
Quote:
Originally Posted by prashanth1414
Yes im using a valid hostname. Running the script with scp command on linux
Execution command:./filename.ksh

Im using scp command in this script to copy it from my home directory to the hostserver.
scp -p my/dir username@hostserver:dest/dir
Well, you're not specifying the path correctly, no matter WHAT *nix you're using. You need the leading "/", such as "scp -p /my/dir user@host:/dest/dir", so I'm not surprised it's failing. Also, you're trying to copy a DIRECTORY...you need to recurse it, so look at the "-r" flag. Again, this is common for ALL *nix systems.
Quote:
Originally Posted by prashanth1414 View Post
Code:
#!/bin/ksh

RC=0
errmsg="`basename $0` `date +%y-%m-%d-%H-%M` return cd: $RC"
 
OWNER=PEND
export SCRIPTS_DIR=`dirname $0`
STELLANT_DIR=/source/directory
STELLANT_PARSER=/dest/dir/filename
STELLANT_SERVER=servername
scp -p $STELLANT_DIR/filename.dat username@$STELLANT_SERVER:$STELLANT_PARSER

 rc=$?
  if [[ $rc != 0 ]]; then
       addtoerrmsg=" failed."
       print $addtoerrmsg
       RC=8
       errmsg="$errmsg $addtoerrmsg"
       
   else
       print "xxx.dat move to $STELLANT_SERVER:$STELLANT_PARSER successful."
   fi

# Send page if errors.

if [[ $RC > 0 ]]; then
   $SCRIPTS_DIR/error.ksh $OWNER $errmsg
   print "paging"
fi

exit $RC
Ok, so you posted a script...but still haven't said if you're having problems copying this script to the Linux box, and if it's there, what error(s) you're getting, or how you're running it.

Basics:
  • Copy script from Solaris system to Linux system. Do this however you want...USB drive, SCP, FTP, NFS...doesn't matter. Copy them.
  • Make sure they're executable. Do an "ls -l", and set it to be executable with the "chmod 755" command at the least.
  • RUN the script with "/path/to/script.name", or "./script.name"
  • See if it works.
Again, if it DOESN'T, then open the script up. Look at EACH LINE, ONE AT A TIME. See if the command(s) are correct...run them in a terminal window, and see what they do/return, as compared to what it does on the Solaris box. Modify the commands as needed. This goes for variables too, like the directory names you posted above. Do they EXIST? If not, create them...make sure they're readable/writeable as necessary.

If you're having trouble with this, perhaps the administrator at your company can help you with the basics.

Last edited by TB0ne; 06-24-2013 at 10:00 AM.
 
Old 06-24-2013, 10:17 AM   #15
prashanth1414
LQ Newbie
 
Registered: Jun 2013
Posts: 10

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
run command:./script.name
error: connect to host servername port 22: Connection refused
lost connection
scriptname.sh failed.

This is the error which i get when i copy my script from linux box to the Stellant server which i mentioned in the script.Im using scp to perform this task.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue faced in migration of ksh scripts from SunOS to Linux senthilkumar.cud Linux - General 2 08-24-2012 08:29 AM
Aix - Linux Scripts Migration Issues kumarancs Linux - Newbie 4 09-07-2011 11:50 AM
Solaris to Linux Migration? soupbone38 Solaris / OpenSolaris 2 02-28-2009 03:51 AM
Porting ksh script from Solaris to Linux Gives unmatched if error markatharvestinfotec Programming 4 08-28-2008 01:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration