Gossamer Forum
Home : Products : Links 2.0 : Discussions :

How to run a program from unix shell

Quote Reply
How to run a program from unix shell
I have a program to change file entensions
within a directory but it says to run from
the unix shell.How do I do that?
#!/usr/local/bin/perl
#
###################
# Renamer
# Written by Mike Wheeler 6/24/96
# Copyright 1996, All rights reserved
#
# This script is for changing the file extension on all the files (with
# the original file extension) in a directory. For example to make all
# your .html files into .shtml files or .html files into .htm files.
##################

$file_dir = "/usr/home1/masstab/html/foofighters";
# This is the directory where all the files to be renamed are.


$ext1 = ".crd";
# This is the original file extension (begiining with a period)


$ext2 = ".txt";
# This is the new file extension (beginning with a period)


# That's it! Be sure to chmod the script to 755 and run it from the
# Unix shell (rather than your browser).
###################
opendir(FILES,"$file_dir");
@allfiles = grep(!/^\.\.?$/,readdir(FILES));
closedir(FILES);
foreach $file(@allfiles){
$newfile = $file;
$newfile=~ s/$ext1/$ext2/g;
rename("$file_dir/$file","$file_dir/$newfile");
}
exit;

Quote Reply
Re: How to run a program from unix shell In reply to
All you have to do is the following:

1) Connect to the directory where the script is located:

Code:
cd /cgi-bin/

2) Then to run the script, use the following:

Code:
perl script.cgi

Change script with the name of your script.

BTW: What does this have to do with LINKS? Just curious!

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums