LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-14-2012, 10:25 PM   #1
kraml
LQ Newbie
 
Registered: Jan 2012
Posts: 16

Rep: Reputation: Disabled
Question Make Linux Translate String c:\data\ As /mnt/ntfs/data/


I have a database (Zotero). It was created and is still frequently used in Windows. (No choice.) It contains links to PDFs (e.g., c:\data\file.pdf). I also access it in Linux, under Linux, on the same system (dual boot). The Windows directory c:\data\ is /mnt/ntfs/data/ in Linux. When the string c:\data\ appears in the database in Linux, I want Linux to translate that to /mnt/ntfs/data/. Then, in Linux, I would be able to open the linked PDFs. Thx kraml.
 
Old 01-14-2012, 11:08 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
It depends on how you receive the data in Linux.

In other words, are you using a shell script to access the database? Are you using a program to access the database? Are you seeing database information through a PHP/ASP web page on an internal web site?

If you are accessing the information in a shell script, then this command will translate it for you (which you will have to incorporate into your script):
Code:
# Assume the "c:\data\file.pdf" was returned in the variable PDF_LOCATION
# WARNING: Some care needs to be taken to make sure that the \'s were escaped properly when
# the location was returned/stored in PDF_LOCATION
LINUX_PDF_LOCATION=$( echo "${PDF_LOCATION}" | sed 's@c:\\data\\@/mnt/ntfs/data/@' )
If you are accessing the database info through a program, then you need to modify the program to do the substitution.

If you are accessing it through an internal web site, you'll probably need to have the web site query what browser/operating system you are using, and then do the conversion.

In a nutshell, there is no "global" search-and-replace in Linux. If you need to transform data from A to B, you need to modify it at the point the data is received.

Last edited by Dark_Helmet; 01-14-2012 at 11:10 PM.
 
1 members found this post helpful.
Old 01-15-2012, 01:14 AM   #3
kraml
LQ Newbie
 
Registered: Jan 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Dark_Helmet View Post
It depends on how you receive the data in Linux.
I am accessing the data from within the GUI of the program that creates the database, Zotero (standalone; http://www.zotero.org). I'm not sure I have the skill to penetrate the actual database (MySQL, I think) to see the exact form of the link as it appears in the fields that call linked PDFs. I am also only basically familiar with the inner workings of Linux. If I can create a shell script to start the program, can I (theoretically) set a variable to accomplish what I want for that session, assuming that I can discover the form/string that appears in the PDF link field?

I am going to guess that the answer is no, having re-read your response, and assuming that there are probably many different ways in which Zotero could be making the call to location-x, even if I did know what text string to substitute.

Last edited by kraml; 01-15-2012 at 01:28 AM.
 
Old 01-15-2012, 01:38 AM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Quote:
If I can create a shell script to start the program, can I (theoretically) set a variable to accomplish what I want for that session, assuming that I can discover the form/string that appears in the PDF link field?
I doubt it... at least, not in the way I think you are looking at it.


I don't use Zotero, but based on the page you linked to, Zotero provides a plugin for Firefox. That means the "C:\data\file.pdf" path you are getting is likely embedded as part of a hyperlink. In other words, the page presents you with a link to click on that directs you to the desired PDF.

EDIT:
Your message said that you access it through the GUI used to create the database. I didn't see that on the brief scan of the web site that I made. As an alternative, you might try accessing it with their plugin through Firefox if option #4 seems promising to you.
/EDIT

Assuming that is true, I think you have four options:

1. Modify the plugin itself to convert the path for your particular workstation/computer. This isn't likely because I didn't see any indication that the plugin is open source.

2. Modify the web page that presents the link. I don't know if the web page is available to you or not. I don't know if it's a Zotero-supplied page or an internal web page developed by someone at your company/university/group. If it's a Zotero-supplied page, you probably can't change it here either. If it's an internally-developed web page, you can contact your internal IT staff to see if it's possible for them to do something like I mentioned earlier: change the page to identify what OS/browser you are using and adjust the link path accordingly.

3. Set up a proxy on the linux box. Essentially what happens is, you connect to the local linux box and make a request, the local linux box forwards your request to the server you would normally use, the linux box gets the HTML response, modifies the HTML code whenever it sees the "C:\data\" pattern in a link, and then presents it to your copy of Firefox. This is a very involved process. I would not recommend it except as a last resort--especially for something like this.

4. Search for and/or write a Firefox extension that will modify the links for you. I have seen Firefox plugins that alter the HTML code presented to the user. I do not remember one specifically matching your needs, but there may be one available. There may also be a way to do the substitution through Firefox preferences directly. You'll likely have to do some serious searching.

Lastly, if you haven't already done so, I would suggest posting a message in the Zotero Forums. They would probably be more helpful in pointing you toward what you need.

EDIT2:
I did a little digging and found this page on StackOverflow. It points out that the Greasemonkey addon for Firefox can do HTML manipulation using Javascript. Furthermore, there is a collection of pre-written scripts available at Userscripts. It may be worth a look to see if there are any scripts that might be close enough to what you want so that you can modify it easily.

EDIT3:
Last edit... I did a quick search for "modify link target" at userscripts, and found this entry that looks spot-on for the kind of thing you need.

Last edited by Dark_Helmet; 01-15-2012 at 01:53 AM.
 
1 members found this post helpful.
Old 01-15-2012, 10:48 AM   #5
kraml
LQ Newbie
 
Registered: Jan 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Thank you very much, Dark_Helmet, for your kind and detailed responses. I will ponder these and research further at the links you have provided! kraml
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to translate data from a CSV file to a MySQL Database? wowsignal Programming 6 09-06-2010 09:34 PM
How can I write data to a NTFS partition while in Linux? oblador Slackware 3 06-07-2006 11:44 PM
copying data to file:/mnt/hd on mandrake 10 star2a Linux - General 0 06-15-2004 08:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration