[ critical ] Migration from Shellscript to Perl or Python ?


 
Thread Tools Search this Thread
Top Forums Programming [ critical ] Migration from Shellscript to Perl or Python ?
# 1  
Old 05-18-2011
Error [ critical ] Migration from Shellscript to Perl or Python ?

Hello all,

I'm having some doubts about which language to choose to migrate some shell scripts that I have. All scripts work the same way:

1) access the database Pgsql / Mysql
2) HTTP request to extract data
3) Extract data fields through regular expressions
4) Parallel processing

As an example, I'll post below a piece of code that have:

Code:
for isList in ${isServersDual[@]} # loop over mysql table to extract servers
    do
        echo -en  Integration Server '\E[33m'"\033[1m$isList\033[0m\n\n"
        for PACKAGE in `ls *.zip | cut -f1 -d'.' | sort`
            do
                #extract package status ( ON/ OFF ) 
                packageStatus=`wget -O-  -q --http-user=$user --http-password=$pass "http://$isList/invoke/wm.server.packages/packageList" | sed -n /$PACKAGE\</,/TABLE/p | sed -n '5p' | sed -e 's/<[^>][^>]*>//g' -e '/^ *$/d'`
                
                # Actual installed package version
                remotePackageVersion=`wget -q -O- --http-user=$user --http-password=$pass "http://$isList/WmRoot/package-info.dsp?package=$PACKAGE" |  sed -n '/Version/{N;p;}' | sed '2!d' | cut -c 54-57 | cut -f1 -d'&'`
                # Version of the package to be installed
                localPackageVersion=`unzip -qo $PACKAGE manifest.v3 | xargs cat manifest.v3 | sed -n '/\"version/p' | cut -f2 -d'>' | cut -f1 -d'<' | head -1`
                
                #
                # Package version compar.
                if [[ $packageStatus == true ]]
                    then
                        if [[ $remotePackageVersion ==  $localPackageVersion ]]                
                            then    
                                echo -en [ '\E[32m'"VERSION MATCH\033[0m" ]" $PACKAGE\n"
                                echo -en " Installed version      : $remotePackageVersion \n"
                                echo -en " Local package version  : $localPackageVersion\n\n"
                        else
                                echo -en [ '\E[33m'"\033[1mDIFERENT VERSION\033[0m" ]" $PACKAGE\n"
                                echo -en " Installed version      : $remotePackageVersion \n"
                                echo -en " Local package version  : $localPackageVersion\n\n"
                        fi
                else
                    #echo "" >/dev/null                
                    echo -en [ '\E[31m'"DISABLED\033[0m" ]" $PACKAGE\n"
                fi
                rm manifest.v3
        done        
done

Currently, I am migrating to PHP (it must be compatible with windows / linux), it works, I have more performance, but I feel that I am not using the most suitable language ... I think my solution may be between Perl and Python.

But which one should use? Considering the criteria that I mentioned at the beginning?


Thanks!
# 2  
Old 05-18-2011
I would go with python. I think these high level languages will easily support the requirements you have mentioned. Now it is upto you which language you prefer doing it.
# 3  
Old 05-18-2011
Hi,


It could be Python or Perl, as I do not program in those languages​​, I would have to learn from the beginning.
# 4  
Old 05-18-2011
What is your requirement about parallel processing here. Is that threading ?
# 5  
Old 05-18-2011
Yes,

Using the code i described at first post, if i insert an & after the last done, i can get package version check loop for each server. Its possible do that in python?
# 6  
Old 05-18-2011
Python syupports threads, as your not sharing much data between your threads, it should be possible to use threads with ease.
# 7  
Old 05-18-2011
I don't think there are many differences between Perl or Python as far as functionality and speed are concerned. From my point, it boils down to 2 questions:
  1. Which one you feel more comfortable with
  2. Which one is easier to maintain by others

As for the first question, pick any tutorial for each language to get an overview, and then try to do some simple scripts. The second question is harder to answer, since it depends on who will have to maintain the scripts besides you, or maybe after you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python/Perl/Shell ??

Hi All, I'm confused what to use (Python/Perl/Shell), I have a scenario here wherein i need to process a data which might have millions of records in tabular format, my task is to find the {0,null,NA} in each and every column and also inform the end user that this column has this many values... (2 Replies)
Discussion started by: nikhil jain
2 Replies

2. AIX

AIX - FC Switch migration, SAN Migration question!

I'm New to AIX / VIOS We're doing a FC switch cutover on an ibm device, connected via SAN. How do I tell if one path to my remote disk is lost? (aix lvm) How do I tell when my link is down on my HBA port? Appreciate your help, very much! (4 Replies)
Discussion started by: BG_JrAdmin
4 Replies

3. Shell Programming and Scripting

Compare and contrast Perl v Python

Anyone care to give me the cliff notes as to why one would want to use perl vs python? Unix Solaris over here. Have capability to run both perl and python and bash/ksh and others. Now what I am interested in using unix and its programs for large amounts of data, sql (done in Unix SAS)...etc.... (5 Replies)
Discussion started by: sas
5 Replies

4. Shell Programming and Scripting

perl, python, or ? for a particular task

I have a client that needs some data downloaded from a website periodically. The problem is that the data is not available directly (i.e. ftp) and must be accessed via logging in to the site, selecting the data manually, then finally clicking a link to grab the zip file. The site does not have an... (2 Replies)
Discussion started by: shunk wugga
2 Replies

5. Shell Programming and Scripting

Perl Vs Python

Hello all, I am in a bit of dilema here. I want to implement a suite. it involves a lot of text file processing and shell scripts . which one to use perl or python ? (4 Replies)
Discussion started by: achak01
4 Replies

6. Homework & Coursework Questions

Help with Simple Perl/Python Script

I have the following problem, which I need done in Perl/ or Python using Unix/linux filters... 1. You have a very large file, named 'ColCheckMe', tab-delmited, that you are asked to process. You are told that each line in 'ColCheckMe' has 7 columns, and that the values... (1 Reply)
Discussion started by: Swapnilsagarwal
1 Replies

7. Shell Programming and Scripting

Help with Simple Perl/Python Script

I have the following problem, which I need done in Perl/ or Python using Unix/linux filters... 1. You have a very large file, named 'ColCheckMe', tab-delmited, that you are asked to process. You are told that each line in 'ColCheckMe' has 7 columns, and that the values in the... (1 Reply)
Discussion started by: Swapnilsagarwal
1 Replies

8. Shell Programming and Scripting

Perl to Python

Friends How to convert this perl notation to Python ${$$hashptr{$sys_Id}}{$doc_Id} = $docstr; Jagan (0 Replies)
Discussion started by: jaganadh
0 Replies

9. Shell Programming and Scripting

Perl style i++ in Python

friends Is it possible to implement perl style autoincriment in python? e.g i++ How it can be represented in python Jagan (1 Reply)
Discussion started by: jaganadh
1 Replies

10. Shell Programming and Scripting

Perl Application Migration From MPE To Unix

Hi, Iam working on migration of perl applicaion from MPE/ix OS to UNIX. Perl Application uses MPE::File Package which cannot be used in HPUX. I have identified IO::File and Filehandle package as replacement. Will the functionality of the MPE Package & Unix filehandle Package will match? ... (0 Replies)
Discussion started by: tc.omkumar
0 Replies
Login or Register to Ask a Question