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
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT BSD
return
exit(1) User Commands exit(1)NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps
SYNOPSIS
sh
exit [n]
return [n]
csh
exit [ ( expr )]
goto label
ksh
*exit [n]
*return [n]
DESCRIPTION
sh
exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of
the last command executed (an EOF will also cause the shell to exit.)
return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe-
cuted.
csh
exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the
expression expr.
The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches
for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to
jump to a label that occurs between a while or for built-in command and its corresponding end.
ksh
exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8
bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing
a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit
except for a shell which has the ignoreeof option (See set below) turned on.
return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the
least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return
is invoked while not in a function or a '.' script, then it is the same as an exit.
On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways:
1. Variable assignment lists preceding the command remain in effect when the command completes.
2. I/O redirections are processed after variable assignments.
3. Errors cause a script that contains them to abort.
4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari-
able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not
performed.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO break(1), csh(1), ksh(1), sh(1), attributes(5)SunOS 5.10 15 Apr 1994 exit(1)