Jump to content

Recommended Posts

Posted (edited)

Greetings,

 

Using an script from an old post in this forum I’m trying to turn an AD user profile path into a compatible OSX accepted path. I had to change the scripting a bit because it didn’t work for me as it was, but due to my major lack of knowledge in mac scripting its not giving me the result that I want. As you can see from below, the first few commands give me what I want but when it comes to setting the MacFormattedDirectory variable it goes wrong. Please can anyone review the below commands and let me know where I’m going wrong.

 

Thanks

 

WinFormattedDirectory=`dscl /Active\ Directory/DOMAIN/All\ Domains -read /Users/$USER SMBHome | grep \\\\\\\\.* -o`

echo $WinFormattedDirectory returns \\server\homes$\students\2010\test2010 (as expected)

 

ShortenedWinFormattedDirectory=`echo $WinFormattedDirectory | sed s/\\\\\\\\server/\\\\/Volumes/`

echo $ShortenedWinFormattedDirectory returns \/Volumes\homes$\students\2010\test2010 (works fine, even though i dont really want the first forward slash)

 

MacFormattedDirectory=`echo $ShortenedWinFormattedDirectory | sed s/\\\\/\\//g`

echo $MacFormattedDirectory returns \Volumes\homes$\students\2010\test2010 (wrong, supposed to turn all backslashes into forwardslashes)

 

echo $ShortenedWinFormattedDirectory | sed s/\\\\/\\//g

returns //Volumes/homes$/students/2010/test2010 (this is what i am looking for)

 

My question is though its running the same command why is the result different when im setting the MacFormattedDirectory variable (which is what i need to be able to do)?

 

Thanks

James

Edited by jjohnsoncantell

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...