Convert NAS URL to Physical Path & visa-versa


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert NAS URL to Physical Path & visa-versa
# 1  
Old 11-06-2018
Convert NAS URL to Physical Path & visa-versa

sometime the user gives me the Linux NAS path URL which is accessible usings windows explorer like below:

Quote:
\\lntshare\NT-Share\Application_Logs\Prod\OHS_LOGS_10042018
This URL translates to the below physical path on Linux host

Quote:
/mnt/lntshare/Application_Logs/Prod/OHS_LOGS_10042018
Below is what I wish to achieve:

1. Detect if the path provided is NAS URL starting with "\" or a Physical Linux path starting with "/"

My solution

for detecting NAS URL: if [ $myurl = '\*' ]; then

for detecting Physical Path: if [ $myurl = '/*' ]; then

Can you please let me know if this approach is good ?

2. If the path is NAS (\\)URL then convert it to Physical Linux Path (starting with /)

3. If the path is a physical Linux Path then convert it to a NAS URL.

Below is the df output on the Linux server:

Code:
df -k | grep lntshare
//lntshare/NT-Share  760637032 625989808 134647224  83% /mnt/lntshare

# 2  
Old 11-06-2018
Code:
myurl='\\whatever'

case "$myurl" in
\\\\*)
        echo "Network path"
        ;;
/*)
        echo "Absolute filesystem path"
        ;;
*)
        echo "Invalid path"
        ;;
esac

# 3  
Old 11-06-2018
what is the best way to convert NAS to PHYSICAL and PHYSICAL to NAS URL ?

Last edited by mohtashims; 11-06-2018 at 06:23 PM..
# 4  
Old 11-07-2018
Depends what your shares are.
# 5  
Old 11-07-2018
I think that you need to explain why you need to convert these pathnames??

Code:
\\lntshare\NT-Share\Application_Logs\Prod\OHS_LOGS_10042018

looks like a Samba path to a Windows share on a server called lntshare so lntshare resides on a Windows server or something else running Samba server.

However,
Code:
/mnt/lntshare/Application_Logs/Prod/OHS_LOGS_10042018

looks like a local disk or a NFS disk is mounted under /mnt on a Unix or Linux box.

I understand that you are saying that these two paths are one and the same so please explain the topology, the hardware, network connectivity,etc.

I'm guessing that you are trying to modify some Samba script to access the device via a Linux host instead. Am I right?

Last edited by hicksd8; 11-08-2018 at 10:46 AM..
# 6  
Old 11-15-2018
Guys this has to do with a string conversion only based on output of df as was shared in the Original Post.
# 7  
Old 11-15-2018
Quote:
Originally Posted by mohtashims
Guys this has to do with a string conversion only based on output of df as was shared in the Original Post.
This doesn't look like it is just a string conversion to me.

If you think this is just a string conversion, please specify exactly what the steps are in a conversion from a string starting with a backslash character to a string starting with a forward slash character AND specify exactly what the steps are in a conversion from a string start gin with a forward slash character to a string starting with a backslash character. Note, of course, that the only data that any of the steps in either set of steps can reference are the output from a df command and the input string.

If you can't write down all of the steps needed to do that, we have to assume that we can't do what you've asked us to do for you.

After you write down all of the steps involved in both conversions, try writing code to do perform those steps and show us what you've done.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies

2. Red Hat

Physical path of NIC/HBA

How can I get the physical path i.e. slot#, port# etc. using a command on linux physical server? Looking for a command for mapping. thanks... (3 Replies)
Discussion started by: snchaudhari2
3 Replies

3. AIX

AIX swap space, physical memory & cache

Hi, I am new to AIX, Can someone please help me how to know the swap space, total physical memory and system cache? We are using AIX 5.3. Thanks! (3 Replies)
Discussion started by: Phaneendra G
3 Replies

4. UNIX for Dummies Questions & Answers

How to convert relative path to absolute path?

Hello Everyone, I want to convert Relative Path - /home/stevin/data/APP_SERVICE/../datafile.txt to Absolute Path - /home/stevin/data/datafile.txt Is there a built-in tool in Unix to do this or any good ideas as to how can I implement this. -Steve (5 Replies)
Discussion started by: qwarentine
5 Replies

5. Shell Programming and Scripting

Text substitution & getting file name from url

hi, sorry if this seems trivial. i have a file url.txt which consists of a list of urls (it was supposed to be my wget -i file). however, since the server from which i am trying to download uses redirect, wget dows not remeber the filename of ther original url will save to a file name which is... (3 Replies)
Discussion started by: texttoolong
3 Replies

6. Web Development

Apache mod_rewrite: from 'friendly' url to actual path

I'd like to translate a friendly url such as: http://www.xxxyyyzzz.com/page/12345678/ to: http://www.xxxyyyzzz.com/page/12/34/56/78/ Seems simple enough, but I cannot figure out how. Any one done this before? (2 Replies)
Discussion started by: markericksen
2 Replies

7. Shell Programming and Scripting

sed help to convert from lowercase to uppercase and vice versa!

Hello, can sed be used to convert all letters of a file from uppercase to lowercase and vice versa?i know tr command can be used but with sed is it possible? i came up with this :- sed 'y///' file1 actually the above command is also not working! Please help me. Thanks in advance :) (6 Replies)
Discussion started by: salman4u
6 Replies

8. Shell Programming and Scripting

Convert Epoch Time to Standard Date and Time & Vice Versa

Hi guys, I know that this topic has been discuss numerous times, and I have search the net and this forum for it. However, non able to address the problem I faced so far. I am on Solaris Platform and unable to install additional packages like the GNU date and gawk to make use of their... (5 Replies)
Discussion started by: DrivesMeCrazy
5 Replies

9. Web Development

CAN TCPDF USE fopen() or Convert URL To PDF?

Dear all, I'm a newbie for PHP and TCPDF ,I have to change the URL to PDF, so I used FPDF , But it cannot convert most of the advanced HTML tags. So explored again and found TCPDF , it can do most of the tag but I cannot found to change URL to PDF. So Does anyone can point the example... (0 Replies)
Discussion started by: athae
0 Replies

10. UNIX for Dummies Questions & Answers

default url path

flavor AIX where oh where do I set the default url path? at one point and time the path was set to a specific dir, i.e. when I access http://server.com/page.html I am hitting a page saved off in dir1/dir2/dir3/page.html. but, how do I alter that default path? I don't have a clue what web... (5 Replies)
Discussion started by: Xiix
5 Replies
Login or Register to Ask a Question