Need help with changing bash to perl


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need help with changing bash to perl
# 1  
Old 06-30-2008
Need help with changing bash to perl

Hi guys,
I am converting a bash script to perl. I need lots of help and pointers on how to make the script work. Any help would be greatly appreciated. Here is what I have:
#!/usr/bin/perl
#Decrypt Files
$dir = "/usr/bin/gpg;
opendir(PGP_DIR, $dir) || die "can't opendir $dir: $!";
@pgp_files = grep { /pgp$/ && -f "$dir/$_" } readdir(PGP_DIR);
closedir(PGP_DIR);

for my $pgp_file (@pgp_files) {
my @output = `usr/bin/gpg --passphrase-fd 0 $pgp_file < .sunspot`;


#Move Decrypted files to pgps/End of Month Folder

move("pgp_file", "pgps/20080531") || die "move failed: $!";

#Change directory to txt
chdir "$idtdata/txts" || die "Can't change to $idtdata/txts: $!\n";

#Move text files
mv../*.txt .;

#Remove Database files
rmdir loadfile.seq;

#Update text files

$some_dir = " "
opendir(TXT_DIR, $dir) || die "can't opendir $some_dir: $!";
@txt_files = grep { /txt$/ && -f "$some_dir/$_" } readdir(TXT_DIR);
closedir(TXT_DIR);

for my $txt_file (@txt_files){
my @output = `./cvnidtf.pl $txt_file`
`curl -u mydriveSmilieasswd --disable-epsv -T loadfile.seq ftp://11.1.11.1`
`mysql -u tdrive -h 11.1.11.1 -ppasswd < ldinsdocs.sql`;


#Move Updated text files to hold in Beginning of the month folder
move("txt_files", "hold/20080501") || die "move failed: $!";
# 2  
Old 06-30-2008
Can you please tell us what exactly is not working?

By the way, I'm curious that if the script is full of shell commands like that, why make the switch to Perl? Frankly, what you have looks more like shell script, rather than Perl.
# 3  
Old 07-01-2008
Moreover, isn't 'move' specific function of File:Copy perl module or it's already builtin ?
# 4  
Old 07-01-2008
the program started out as shell and now my supervisor wants it converted to shell for whatever reason when we do a lot of bash shell scripting.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing from bash to ksh

Hello, I want to run a script written in ksh but my default shell is bash as root e.g in the script it has #!/bin/ksh i have gone into /etc/passwd to change it from :/bin/bash to /bin/ksh but still giving me an error when running scripts such as ./installer -bash: ./installer: /bin/ksh:... (3 Replies)
Discussion started by: DOkuwa
3 Replies

2. Shell Programming and Scripting

Changing date using bash script

I am trying to change dates in a bash script. I have a start time and an endtime and want to increment the times. Basically the month and day have to be incremented in a loop to create two strings, stm and etm defining the start and end times. stm="2014-05-13T00:00:00"... (4 Replies)
Discussion started by: novilatte
4 Replies

3. UNIX for Beginners Questions & Answers

Connecting and changing variables in Bash script

#!/bin/bash X=$(</home/cogiz/computerhand.txt) # (3S 8C 2H 6D QC 8S 4H 5H) Y=$(</home/cogiz/topcardinplay.txt) # KS A=( "${Y::1}" ) B=( "${Y:1}" ) for e in ${X}; do if ]; then # searching for valid cards K,S or 8 ... (0 Replies)
Discussion started by: cogiz
0 Replies

4. Shell Programming and Scripting

Changing IFS in bash function

I have a function in bash that takes arguments. does IFS work in a function or does it apply only to the main script? (1 Reply)
Discussion started by: kristinu
1 Replies

5. Shell Programming and Scripting

Changing script from csh to bash

Hello Guys I have a script working fine on csh, but I would like to change it to bash, how I should change this command to be able to work as bash script. :wall: if ( $fsw > "0" ) then foreach swath ( `awk 'BEGIN {for (i='$fsw';i<='$lsw';i++) printf ("%s\n", i) }'` ) ## work to be done... (2 Replies)
Discussion started by: jiam912
2 Replies

6. HP-UX

Changing default shell to bash

According to multiple sources you should not change the default shell to bash for the root user because it will make the system unbootable. Is there a safe way to launch bash for root when logging in? Perhaps I can edit /etc/profile or add it to a startup script somewhere? (2 Replies)
Discussion started by: bstring
2 Replies

7. Shell Programming and Scripting

Bash - changing a color of a substring

Hello! I need to write a bash script for my university classes, and I came up with an idea of a program that would test the speed of typing - there is some random text that you have to rewrite, and the script measures time, number of mistakes etc. The text would be visible on the screen all... (3 Replies)
Discussion started by: xqwzts
3 Replies

8. Shell Programming and Scripting

changing cron using bash script

How can I change the cron entries only for ABC and XYZ from dosomething_1.0.sh to nowchanged_2.0 using a bash script ? Any help will be appreciated. # # ABC 00,05,10,15,20,25,30,35,40,45,50,55 * * * * /mydir/dosomething_1.0.sh 1>/dev/null 2>&1 # # ## # DEF... (4 Replies)
Discussion started by: jville
4 Replies

9. Shell Programming and Scripting

bash changing file name

I want to run some unix commands on one file..let say if i change the name and that name of file is present already. I dnt want to change that presnt file but instead of that make another one with different name eg.. usa.txt if it is there make usa.txt.1 something like that Also one more... (5 Replies)
Discussion started by: Learnerabc
5 Replies

10. Shell Programming and Scripting

Changing text colour in bash

I am doing a basic script to check if services are disabled, and I was wondering how to change to colours for PASS and FAIL to green & red respectively. #!/usr/bin/bash clear TELNET=`svcs -a | grep telnet | awk '{print $1}'` if then RESULT=PASS else RESULT=FAIL fi... (3 Replies)
Discussion started by: detatchedd
3 Replies
Login or Register to Ask a Question