![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Call a perl script inside a shell script | chriss_58 | Shell Programming and Scripting | 3 | 12-01-2008 04:28 AM |
| Need to convert ksh script to Perl | rahimm1 | Shell Programming and Scripting | 1 | 10-21-2008 08:47 AM |
| Include PERL script with in the unix shell script | ganapati | UNIX for Dummies Questions & Answers | 1 | 04-29-2008 12:18 PM |
| convert the below perl sript to shell script | mail2sant | Shell Programming and Scripting | 1 | 04-04-2008 01:36 PM |
| convert unix script to perl | gholdbhurg | Shell Programming and Scripting | 2 | 03-25-2008 01:42 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
convert PERL script to SHELL script
Hi all experts,
I am new to Unix. Could you please help me to convert the following PERL script to SHELL? I will appreciate. #!/bin/sh use strict; use warnings; my $robot_num = 0; my %rob_tapes; foreach (`/usr/openv/volmgr/bin/vmquery -l -rn $robot_num`) { $rob_tapes{(split)[0]} = 1; } foreach (`/usr/openv/netbackup/bin/admincmd/bpmedialist -l`) { my @line = split; next unless exists $rob_tapes{$line[0]}; #remove for all my $status = ""; if ($line[14] & 0x1 ) { $status .= " FROZEN"; } if ($line[14] & 0x8 ) { $status .= " FULL"; } if ($status) { print "$line[0] $status\n"; } } |
|
||||
|
From PERL script to single line shell - "What's the status of my Netbackup Media?"
Heh. This took some sweating and cursing. Finally had to talk to the AWK guru in my office.
Code:
bpmedialist -l | awk '{print "echo `echo \"obase=2;"$15+4096"\" | bc` "$1}' | sh | cut -c10,13,14-99 | sort -n -n
I presume you're doing this so you can eject full and/or frozen tapes from your robot and load available tapes into the robot. You could put this in crontab and have it email to you right before you get to work every day, so you have an action plan for being the robot stableboy. Curtis W. Preston has an excellent script out there called CLAM (Curtis' Library Automation Menu) that is an great place to look. It uses Perl but also includes easy "shove tapes into robot" and "extract tapes from robot" that is much faster than goofing with the GUI. We had to do minor tweaks to make it work with Netbackup 6.5. |
|
||||
|
Hi i could display only FULL/FROZEN ? I also want to have column which will show the status of the tape like
00 full 01 frozen 01 full Now it only displays # bpmedialist -l | awk '{print "echo `echo \"obase=2;"$15+4096"\" | bc` "$1}' | sh | cut -c10,13,14-99 | sort -n -n 00 000004 00 000005 00 000007 00 000009 00 000015 00 000018 00 000021 00 000023 00 000024 00 000025 00 000027 00 000028 00 000032 00 000039 01 000014 10 000001 10 000002 10 000008 10 000011 10 000013 10 000016 10 000017 10 000020 10 000022 10 000026 10 000030 10 000031 10 000034 10 000035 10 000037 10 000038 10 000040 # Do i have to write if else statement withe the above shell so that when it is 10 it will display FULL and when it is 01 it will display frozen? Please give me some feedback. |
|
|||||
|
Something like this:
Code:
bpmedialist -l | awk '{print "echo `echo \"obase=2;"$15+4096"\" | bc` "$1}' | sh | cut -c10,13,14-99 | sort -n -n | while read STATUS TAPE ; do
case $STATUS in
00) STATUS=?? ;;
01) STATUS=?? ;;
10) STATUS=?? ;;
esac
print "$TAPE $STATUS"
done
|
![]() |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|