Help needed, linking to file in different sub-folder


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help needed, linking to file in different sub-folder
# 1  
Old 09-12-2011
Help needed, linking to file in different sub-folder

Hello,

I'd really like some help on this, a PERL-CGI script (complete working script is below).

How can I add the server's root folder (folder_f) to this:

~ s/_e\.shtml/_f\.shtml/

This bit of code searches all occurences of _e.shtml and replaces them with _f.shtml (it being in the same folder).

Yet, in between that, I would like to be able to add the server's root of "folder_f" folder in there, or done another way if it has to.

My script is called "change-language.pl" - which has a hyperlink to it in "file_e.shtml". When clicked, it will try to find the file "file_f.shtml".



For example of what I would like it to do:

~ s/_e\.shtml/(Link-to-FOLDER_F)_f\.shtml/ (found in script below, but I added (FOLDER_F).

I tried: $calling_page =~ s/_e\.shtml/'s/^/$.\f'\/_f\.shtml/;

but it did not work. It brings me to the same _e.shtml file.


I would really appreciate anyone's help on this one, as I can't seem to get it right, with what I know so far.

The complete script is below, which works but only if both language files (file_e.shtml and file_f.shtml) reside in the same folder. I need to be able to have the script work, so that it will find the file (file_f.shtml) but in a different sub-folder on the server's root called "FOLDER_F" folder.

In the part $calling_page =~ s/_e\.shtml/_f\.shtml/; of the script, is there a way to do this:

$calling_page =~ s/_e\.shtml(Link-to_FOLDER_F)/_f\.shtml/; - FOLDER_F being in parentheses is where I would like to be able to have the script modified so that it goes to a sub-folder and get file_f.shtml in FOLDER_F sub-folder.

What I have so far follows WORKS, but only works if both _e.shtml and _f.shtml files are in the same folder:

Code:
#!/usr/bin/perl
#
#
# get the URL for the Web page that called this script
$calling_page = $ENV{'HTTP_REFERER'};


if($calling_page =~ /(.*)\#.*/) {

# # only take the first part up to the #
$calling_page = $1;}

# ignore any file that is not _e.shtml or _f.shtml and do nothing!

# is this an _e.shtml file?

if($calling_page =~ /_e\.shtml/) {
# replace the suffix

$calling_page =~ s/_e\.shtml/_f\.shtml/;

print "Location: $calling_page\n\n";

# then is this an _f.shtml file?

}

# 2  
Old 09-12-2011
perl modules | Perl HowTo says export PERL5LIB=your_dir

extending the library path

( categories: command line parameters | perl modules )
By default perl looks for modules in the standard library path and the current directory. Sometimes you need to use some modules that are installed in non standard locations; there are several ways to deal with this situation:
-- Install the module somewhere in the standard library path
If you have administrator privileges, then the best solution is to install the modules in any of the system defined library paths (you can get the paths executing perl -le 'print foreach @INC').
-- Set the environment variable PERL5LIB
Perl will look for modules in the directories specified in PERL5LIB environment variable before looking in the standard library and current directory, so you can set this variable to locate your modules.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help Needed for creating the folder by checking today's date and, take backup using rsync command

How to create a shell script to create a folder by using the today's date to take backup using rsync command on every evening around 7 pm. Kindly help. Thanks. To be more precise, I want to create a script which matches the today's date with server's date format, if matches then creates the... (2 Replies)
Discussion started by: bakula10
2 Replies

2. Shell Programming and Scripting

Needed script to generate versions for a file and maintian them in a folder

need a shell script for the following requirement how to generate 5 versions of a file in a folder after generating them in a folder i want to maintian the past 2 versions of the file in the folder and i have to delete the the remaining. for example if i ran the script today and tommorow... (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

3. Shell Programming and Scripting

want to move set of file from one folder to another folder

Hi all, let me explain my requirments i am having 5 folder with different name for eg) abc , cdf , efd, rtg, ead each 5 folders contain 15 files i want to move 10 files to some other folder, remain 5 files should be there in the same folder. give me some suggestion on this. (6 Replies)
Discussion started by: natraj005
6 Replies

4. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

5. Programming

dynamic linking of folder name in makefile

i will tell my problem with example: if i have a folder name called sree1.7.3 i know the starting name say sree and also path say /usr/lib. so i want the folder name. and how can i link this folder in makefile thank u sree (1 Reply)
Discussion started by: phani_sree
1 Replies

6. Shell Programming and Scripting

Parse the .txt file for folder name and FTP to the corrsponding folder.

Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and... (3 Replies)
Discussion started by: MeganP
3 Replies

7. Programming

make file - linking

Hi, I have written a makefile and am facing some problem in linking.. This is the first makefile i write.. i think that am just compiling all the .c files and not linking the object files.. can anybody tell me how to link all the .o files??? When i do make all i am getting the following... (1 Reply)
Discussion started by: rvan
1 Replies

8. UNIX for Dummies Questions & Answers

modifying C file and linking back to project files

hi, This is the first time I work in a big C project. All source code files are located in say directory /source/pp and all header files are in /include/pp. I've created a link to both of these directories from my home dir, say /home/ss. So in the /home/ss dir I have the /source/pp and /include/pp... (1 Reply)
Discussion started by: bruins2005
1 Replies

9. Programming

Linking problem while linking to shared library

Hi I'm getting ld: fatal: option -h and building a dynamic executable are incompatible ld: fatal: Flags processing errors When I run ld -shared -L/usr/dt/lib -lDtSvc -o builtin.so Workspace.o after running gcc -fPIC -I/usr/X11R6/include -I/usr/dt/include -c Workspace.c I'm... (6 Replies)
Discussion started by: laho
6 Replies

10. Shell Programming and Scripting

linking unix generated text file to html page

i am trying to link the text files that i generated from my shell script to an html page, to that i can view them using a browser, like internet explorer. i want to open the text files in html page when i enter a command to view the text file from the shell command. please could anyone help... (1 Reply)
Discussion started by: alexd
1 Replies
Login or Register to Ask a Question