Migrating shell scripts

110 pts.
Shell scripts
SQL scripts
We have to move more than 250 shell scripts from a unix to a linux environment, and also 100 sql scripts. Could you please give me some steps or a check list to follow to migrate these from unix to linux?

Answer Wiki

Thanks. We'll let you know when a new response is added.

The problem with shell scripts usually in that they have too many dependencies on external programs, their output, OS specific behavior. The shell syntax itself is hardly a problem.

There is no easy way to migrate. My scenario would include:

1) Learn syntax of the shell (man shellname). You should understand everything in your shell script before migrating. What, why and how every command works and what do you get in result.
2) Determine what shell was used in previous unix (BTW what kind of Unix)? It can be CSH, TCSH, SH, BASH, …
3) Determine what external programs where used in every script (every command that is not described in manual page for that shell is an external program). Do they exist on target system? Do they have the same output/return codes? If not, you should either find a substitution for the command, change shell code or even write your own command (when no substitution available).
4) Some external commands are very OS dependent. I.e. ‘sysctl’, ‘pbind’. You should find either existing analogs or try to redesign your scripts for new OS.
5) Test every script (after reviewing and fixing all dependencies) on target OS.

For SQL scripts if they should be executed on the same type of SQL server there is no much problems. They will work. If the target SQL RDBMS is different, some scripts will probably fail. The sequence of migrating still the same: learn old SQL syntax used in script – learn new SQL RDBMS syntax – understand what script is doing – rewrite it – test it. Not easy and not quick.

For complex 250 shell scripts all the process can take months or even failure to migrate (when no substitutions for commands or no SQL functionality exists on Linux).

Discuss This Question: 1  Reply

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • petkoa
    Hi Chunter, You got a nice advice from Nopius - I'd underline the importance of the last step (#5 :o)). Some points where I recently got problems: (1) It's frequent practice to place /bin/sh in the she-bang (#! ... in the first line of the script) of the shell scripts. /bin/sh is usually a link to the default shell and the default shells are different under different unix and linux flavors. Couple weeks ago I hit such a problem with an installation module of a commercial package with code suitable for SGI Irix and linux - it appeared that the /bin/sh in Irix (and I believe in some other unices too) points to ksh (Korn shell) which is quite unusual under linux and some distributions lack it (mine too :o((). So be sure to find out what /bin/sh is and to download and install the actual shell if your distribution does not have it. (2) Directory structures could differ - and even worse, one can decide to optimize directory structures for some reason and forget to change scripts which depend on these structures - this happened to me couple of days ago (btw, without any migration). Good luck, Petko
    3,140 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: