Sponsored Content
Full Discussion: Convert shell script to Perl
Top Forums Shell Programming and Scripting Convert shell script to Perl Post 302650459 by gvolpini on Sunday 3rd of June 2012 02:16:37 AM
Old 06-03-2012
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...

Code:
find / -perm 777 \( -type f -o -type d \) -exec ls -lid {} \; | while read a b c d e f g h i j
do 
  type=`echo $b | awk '{print substr($0,1,1)}'`
  case $type in
       -) type="f"
          fordname=`basename $j`
          pathname=`dirname $j`;;
       d) fordname=`basename $j`
          pathname=`dirname $j`;;
  esac
  rights=`echo $b | awk '{print substr($0,2,9)}'`

  #write to file: hostname,type('f' or 'd'),file or directory name,pathname(only if type is 'f'),rights,user,group,size,mmm dd hh:mm(or yyyy) 
  echo "`hostname`|$type|$fordname|$pathname|$rights|$d|$e|$f|$g $h $i|$dd|$a\r"
done >/tmp/777permlst`hostname`.psv

Here's a sample of the output this produces:

Code:
pike|d|ssh|/etc/bat2|rwxrwxrwx|root|sys|8192|Jan 18 2008|120602|3097
pike|d|jre|/opt/VRTSob|rwxrwxrwx|daemon|bin|8192|Mar 17 14:02|120602|52505
pike|d|.systemPrefs|/opt/VRTSob/jre|rwxrwxrwx|daemon|bin|96|Oct 24 2007|120602|52510
pike|d|bin|/opt/VRTSob/jre|rwxrwxrwx|daemon|bin|8192|Oct 24 2007|120602|52513
pike|d|IA64N|/opt/VRTSob/jre/bin|rwxrwxrwx|daemon|bin|8192|Oct 24 2007|120602|52527
pike|d|IA64W|/opt/VRTSob/jre/bin|rwxrwxrwx|daemon|bin|8192|Oct 24 2007|120602|52541
pike|d|lib|/opt/VRTSob/jre|rwxrwxrwx|daemon|bin|8192|Oct 24 2007|120602|52553
pike|d|audio|/opt/VRTSob/jre/lib|rwxrwxrwx|daemon|bin|96|Oct 24 2007|120602|52574
pike|d|cmm|/opt/VRTSob/jre/lib|rwxrwxrwx|daemon|bin|8192|Oct 24 2007|120602|52576
pike|d|ext|/opt/VRTSob/jre/lib|rwxrwxrwx|daemon|bin|8192|Oct 24 2007|120602|52582
pike|d|fonts|/opt/VRTSob/jre/lib|rwxrwxrwx|daemon|bin|8192|Oct 24 2007|120602|52588
pike|d|IA64N|/opt/VRTSob/jre/lib|rwxrwxrwx|daemon|bin|8192|Mar 17 14:02|120602|52598
pike|d|headless|/opt/VRTSob/jre/lib/IA64N|rwxrwxrwx|daemon|bin|96|Oct 24 2007|120602|52629
pike|d|motif21|/opt/VRTSob/jre/lib/IA64N|rwxrwxrwx|daemon|bin|96|Oct 24 2007|120602|52631

So I need to do the same thing in Perl...any takers?

Thanks
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

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)} = 1; }... (6 Replies)
Discussion started by: ma466
6 Replies

3. Shell Programming and Scripting

Shell/Perl script to convert to Capitalize case

I need a shell script which will convert the given string within a <title> tag to Capitalize case. E.g "<title>hi man: check this out</title>" to "<title>Hi Man: Check This Out</title>" (11 Replies)
Discussion started by: parshant_bvcoe
11 Replies

4. 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

5. Shell Programming and Scripting

Help: how to convert perl script to shell script

bash$ mdb-schema x.mdb | perl -wpe 's%^DROP TABLE %DROP TABLE IF EXISTS %i; s%(Memo/Hyperlink|DateTime( \(Short\))?)%TEXT%i; s%(Boolean|Byte|Byte|Numeric|Replication ID|(\w+ )?Integer)%INTEGER%i; s%(BINARY|OLE|Unknown (+)?)%BLOB%i; s%\s*\(\d+\)\s*(,?*)$%${1}%;' | sqlite3 x.db ... (1 Reply)
Discussion started by: jackpapa
1 Replies

6. 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

7. Shell Programming and Scripting

Convert perl program to shell

Hi is there a way that i can convert this simple perl program into shell script #!usr/bin/perl -w use strict; use warnings; open INPUTFILE, "uniqprobecoordinates.out" || die "canot open the file $!"; open OUTPUTFILE, ">", "1_4reads.out"; while(<INPUTFILE>) { chomp; ... (3 Replies)
Discussion started by: bhargavpbk88
3 Replies

8. Shell Programming and Scripting

perl to shell convert

#!/usr/bin/perl #************************************************************** # # PERL SCRIPT # This script restarts the Application # # ##************************************************************** $ENV{'IFS'} = ' '; #open(STDERR,">&STDOUT"); #select... (2 Replies)
Discussion started by: srikoundinya
2 Replies

9. Shell Programming and Scripting

Convert perl to shell

Hi I am a novice in scripting .Please help me converting perl script into shell my ($ref) = shift; my $id; my $cnt=0; my $first =0; my $filename ; my $filename1 ; FOREACH:foreach my $r (qw(RET LSH PDM )) { $ref->{$cnt}->{num_errors} =0; $ref->{$cnt}->{num_warnings} =0;... (2 Replies)
Discussion started by: apassi
2 Replies

10. Shell Programming and Scripting

Perl to shell convert

HI All, I am new in shell scripting ,can any one please help me to convert this scripts from Perl to Shell. Thank in advance. $customer=$ARGV; $rows=`hadoop fs -ls /ncip/$customer/|wc -l`; if($rows==3){ print "$customer directory exists , cleaning up ! \n"; `hadoop fs -rm... (1 Reply)
Discussion started by: Atul301
1 Replies
MYSQL_FIX_PRIVILE(1)					       MySQL Database System					      MYSQL_FIX_PRIVILE(1)

NAME
mysql_fix_privilege_tables - upgrade MySQL system tables SYNOPSIS
mysql_fix_privilege_tables --password=root_password DESCRIPTION
Note In MySQL 5.1.7, mysql_fix_privilege_tables was superseded by mysql_upgrade, which should be used instead. See mysql_upgrade(1). Some releases of MySQL introduce changes to the structure of the system tables in the mysql database to add new privileges or support new features. When you update to a new version of MySQL, you should update your system tables as well to make sure that their structure is up to date. Otherwise, there might be capabilities that you cannot take advantage of. mysql_fix_privilege_tables is an older script that previously was used to uprade the system tables in the mysql database after a MySQL upgrade. Before running mysql_fix_privilege_tables, make a backup of your mysql database. On Unix or Unix-like systems, update the system tables by running the mysql_fix_privilege_tables script: shell> mysql_fix_privilege_tables You must run this script while the server is running. It attempts to connect to the server running on the local host as root. If your root account requires a password, indicate the password on the command line like this: shell> mysql_fix_privilege_tables --password=root_password The mysql_fix_privilege_tables script performs any actions necessary to convert your system tables to the current format. You might see some Duplicate column name warnings as it runs; you can ignore them. After running the script, stop the server and restart it so that any changes made to the system tables take effect. On Windows systems, MySQL distributions include a mysql_fix_privilege_tables.sql SQL script that you can run using the mysql client. For example, if your MySQL installation is located at C:Program FilesMySQLMySQL Server 5.1, the commands look like this: C:> cd "C:Program FilesMySQLMySQL Server 5.1" C:> binmysql -u root -p mysql mysql> SOURCE share/mysql_fix_privilege_tables.sql Note Prior to version 5.1.17, the mysql_fix_privilege_tables.sql script is found in the scripts directory. The mysql command will prompt you for the root password; enter it when prompted. If your installation is located in some other directory, adjust the path names appropriately. As with the Unix procedure, you might see some Duplicate column name warnings as mysql processes the statements in the mysql_fix_privilege_tables.sql script; you can ignore them. After running the script, stop the server and restart it. COPYRIGHT
Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc. This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/. SEE ALSO
For more information, please refer to the MySQL Reference Manual, which may already be installed locally and which is also available online at http://dev.mysql.com/doc/. AUTHOR
Sun Microsystems, Inc. (http://www.mysql.com/). MySQL 5.1 04/06/2010 MYSQL_FIX_PRIVILE(1)
All times are GMT -4. The time now is 07:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy