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:

This URL translates to the below physical path on Linux host

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 ?

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

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

Below is the df output on the Linux server:

df -k | grep lntshare
//lntshare/NT-Share  760637032 625989808 134647224  83% /mnt/lntshare
myurl='\\whatever'

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

what is the best way to convert NAS to PHYSICAL and PHYSICAL to NAS URL ?

Depends what your shares are.

I think that you need to explain why you need to convert these pathnames??

\\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,

/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?

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.

If that's the one and only share that will ever be fed into this, then yes, it is. If it's not, it really becomes quite complicated and requires lots more information from you.

Answer our questions faster and you'll get replies faster.