Need to convert ksh script to Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to convert ksh script to Perl
# 1  
Old 10-21-2008
Need to convert ksh script to Perl

Guys I am new to this forum, this may seem like a cheeky request.
I have been asked by my manager to convert this ksh script to Perl. I do not have the foggiest about Perl and would appreciate any help on this.
Basically this scipt automates a recovery process for EMC Legato Networker. It will find all the relevant full and incremental backups for the period of recovery. As at present we have to type in

recover -s (server name) -S ssid
for all savesets which is tedious.
For any one that does this I will buy them a few beers

Code:
#!/bin/ksh
#
#
# 
#set -x
NSR_LOG=`pwd`/nsrssrecover.log
#script -a $NSR_LOG <<EOT

NSR_JUKEBOX="IBM@3.4.1"

NSR_SERVER=sghmgtnwksrv001
NSR_CLIENT=`hostname`
NSR_RECDATE="08/28/08 23:30:00"
NSR_DEST=/tmp/drazen
NSR_FILESYSTEM=/
NSR_LOG=`pwd`/nsrssrecover.log

export NSR_SERVER NSR_CLIENT NSR_RECDATE NSR_DEST NSR_FILESYSTEM NSR_LOG NSR_JUKEBOX


LC_TIME=c

NSR_STARTDATE=`mminfo -s $NSR_SERVER -o t -q "name=$NSR_FILESYSTEM,level=full,savetime<$NSR_RECDATE,client=$NSR_CLIENT" -r "savetime(18)" | tail -1`

print "Volume       Date     Time     Level Name"
printf "%s\n" "--------------------------------------------------------------------------------"

NSR_SAVELIST=`mminfo -s $NSR_SERVER -o t -q "savetime>=$NSR_STARTDATE,savetime<=$NSR_RECDATE,client=$NSR_CLIENT,name=$NSR_FILESYSTEM" -r ssid`
for NSR_SSID in $NSR_SAVELIST
do
    NSR_CLONEID=`mminfo -s $NSR_SERVER  -q "ssid=$NSR_SSID,location=$NSR_JUKEBOX" -r cloneid | tail -1 | sed -e "s/^ *//"`
    if [ -z "$NSR_CLONEID" ]
    then
        print "E000001 Unable to locate saveset localy in library"
        mminfo -s $NSR_SERVER  -q "ssid=$NSR_SSID" -r "volume,location,ssid,cloneid,client,name"
    else
        mminfo -s $NSR_SERVER -q ssid=$NSR_SSID,cloneid=$NSR_CLONEID -r "volume(12),savetime(18),level(6),name" | tail -1
    fi
done

printf "%s\n" "--------------------------------------------------------------------------------"
  
for NSR_SSID in $NSR_SAVELIST
do
    NSR_CLONEID=`mminfo -s $NSR_SERVER  -q "ssid=$NSR_SSID,location=$NSR_JUKEBOX" -r cloneid | tail -1 | sed -e "s/^ *//"`
    if [ -z "$NSR_CLONEID" ]
    then
            exit 2
    fi

    print "recover -iY -s $NSR_SERVER -S $NSR_SSID/$NSR_CLONEID -d $NSR_DEST"
done

exit 0
#EOT


Last edited by bakunin; 10-21-2008 at 09:50 AM.. Reason: added code tags around the code - please consider doing it yourself the next time
# 2  
Old 10-21-2008
Quote:
Originally Posted by rahimm1
Guys I am new to this forum, this may seem like a cheeky request.
I have been asked by my manager to convert this ksh script to Perl.
yes indeed. Your manager paid you to do the job, so i suggest you pick up a Perl book or study the Perl document to get a head start. After that if you still encounter problems, post here again to see if anyone can help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can someone convert this python script to perl

There is a python script that I would like converted to a perl script. If someone has the time to convert the script I would appreciate it. You can find the script below: reboot-mb8600/reboot-mb8600.py at master . j4m3z0r/reboot-mb8600 . GitHub #!/usr/bin/python ''' A hacky script to... (1 Reply)
Discussion started by: azdps
1 Replies

2. Shell Programming and Scripting

Perl Script remove digits and convert

Hello Guy's Quick question which im sure many can answer in seconds. Basically I have a perl script which is running commands to an element and then taking some of the the output and printing it to the screen. One of the outputs is a variable Hex Number. What I would like to do is strip... (1 Reply)
Discussion started by: mutley2202
1 Replies

3. Shell Programming and Scripting

Convert shell script to Perl

Hello,,I have a very small script that contains these lines; and it works perfectly; however I need to use Perl now as I will need to feel variables from a MySQL table into this; to it would be nice to start by converting this first... find / -perm 777 \( -type f -o -type d \) -exec ls -lid {}... (1 Reply)
Discussion started by: gvolpini
1 Replies

4. Shell Programming and Scripting

Help with convert awk script into perl

Input file (a list of input file name with *.txt extension): campus.com_icmp_ping_alive.txt data_local_cd_httpd.txt data_local_cd.txt new_local_cd_mysql.txt new_local_cd_nagios_content.txt Desired output file: data local_cd_httpd data local_cd new local_cd_mysql new ... (9 Replies)
Discussion started by: perl_beginner
9 Replies

5. Shell Programming and Scripting

HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

Hi all, Not sure if this should be in the programming forum, but I believe it will get more response under the Shell Programming and Scripting FORUM. Am trying to write a customized df script in Perl and need some help with regards to using arrays and file handlers. At the moment am... (3 Replies)
Discussion started by: newbie_01
3 Replies

6. Shell Programming and Scripting

convert perl code to shell script

This is about how to Monitoring folder for new files using shell script im doing a project using smsserver tools 3. i have used a perl script to handle incoming messages. the content of each message must be directed to a java program. this program generates the answer to reply to the user... (2 Replies)
Discussion started by: x34
2 Replies

7. Shell Programming and Scripting

Convert .sh script into perl

Good afternoon to you all I really need your help I have the following script developed in .sh and I need to convert it into perl. Can someone help me do it please? Here´s the script: ############################################## ############################################## ... (3 Replies)
Discussion started by: zarahel
3 Replies

8. Shell Programming and Scripting

convert the below perl sript to shell script

perl script: my $logdir = '/smp/dyn/logfiles/fsm/mp/mp'; $logdir = $logdir ."/mp${toDate}*"; i tried to make it..as below .. but not working .. date +%m%d%y logdir = /smp/dyn/logfiles/fsm/mp/mp logdir=$logdir/mp"$date" but it was not working..... can someone please help me out in... (1 Reply)
Discussion started by: mail2sant
1 Replies

9. Shell Programming and Scripting

convert unix script to perl

Hi, I have these lines in a unix script: FILEONE = /<filepath1>/<filename1.txt> FILENEW = /<filepath2>/<filename2.txt> head -5 $FILEONE | sed '1d' > $FILENEW PARAM1 = `cat $FILENEW | awk '{print $2;}' ` echo "Param1 Value: $PARAM1" What's the correct syntax of the above lines if same... (2 Replies)
Discussion started by: gholdbhurg
2 Replies

10. Shell Programming and Scripting

how to convert unix .ksh script to windows .batch script

I am using awk in my .ksh script but when I am trying to run in windows its not recognising awk part of the ksh script , even when I changed it to gawk it does not work, this is how my .ksh and .bat files look like. thanx. #!/bin/ksh egrep -v "Rpt 038|PM$|Parameters:|Begin |Date: |End... (1 Reply)
Discussion started by: 2.5lt V8
1 Replies
Login or Register to Ask a Question