Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yellow

Moderator emeritus
Original poster
Oct 21, 2003
16,018
6
Portland, OR
I've finally lost it.. I just don't understand what I've done wrong, and of course I'm under a time crunch.

Here are the basics of what I'm trying to do...

Because most of the people in this set of labs have personal Macs that don't follow our user naming schemes for AD, I am trying to create a generic mounting script that will (if the file doesn't exist) ask for the user's name and write it to file as text. Then the same script can look at the script for the user's AD username and then mount the drives/shares as appropriate using the correct username, no matter what their current actual user name is..

The issues that I keep encountering are this:

1) When the result is written to a text file, it's not straight text. It's full of control characters. So, "joe" is "^@j^@o^@e". Is there some way that I can simply output it as straight text?

2) I put in safeguards to ask what the script reads from the file always looks right. But in the portion of the script that takes the result from the file and slaps it into a variable that I use as the username in the mount portion of the script
Code:
mount volume "cifs://DOMAIN;"& _placeUsername_ &";share.domain.edu/share$"

never populates. And when I use the same variable to try and open the user's home folder, it doesn't work (well, it works maybe 1 in 50 times, oddly).

Code:
set mountHome to make new Finder window to folder _placeUsername_ of disk "SHARE$"
			set current view of mountHome to list view

BUT, before each of these actions, I ask for the output of the variable and it always works. And when I look at the event logs in Applescript, it's always right.

Code:
mount volume "cifs://DOMAIN;joe@share.domain.edu/share$"
	make new Finder window to folder "joe" of disk "SHARE$"

Finally.. as a test, I edited the file with a text editor and simply changed it to "joe".. and what do you know, it works. Sort of.. there appears to be some sort of carriage return/newline, invisible to me. Because the event log outputs like this:

Code:
mount volume "cifs://DOMAIN;joe
@share.domain.edu/share$"
		file "SHARE$:"
	list disks
		{"Hanso", "Others", "Losties", "Dharma", "Network", "SHARE$"}
	display dialog "(view2) got username from file created: joe
"
		{button returned:"OK"}
	make new Finder window to folder "joe
" of disk "IMMU_HOME$"


Soooo.. Just what am I hoping that you can you, more knowledgeable folks, can help me with?

Can I write straight text to a file from Applescript? No control characters?
Am I supposed to be writing as Unicode?
Do you see a way around my problem here?
 

iMeowbot

macrumors G3
Aug 30, 2003
8,634
0
So, "joe" is "^@j^@o^@e".
All righty ^@ is nul, so it looks like you're getting wide characters when you're expecting to work with 8-bit characters in your commands. You might try dropping the Unicode part to see if that makes the trouble go away, but what does the part that collects and writes the lusername look like (or am I staring right at that part in your post and missing it)?

The extra CR is probably just an artifact of the text editor you're using.
 

yellow

Moderator emeritus
Original poster
Oct 21, 2003
16,018
6
Portland, OR
It occured to me that it might be useful if you saw how I was gathering the text. (correctly so, too :))

Code:
try
	alias _pathToFile  -- This is just looking for the existance of the file.
on error
	display dialog "Please enter your UserID" default answer "Enter UserID here"
	set resultOfUserID to (text returned of result)
	set fileName to (path to documents folder as string) & ".HomeMountUsername-DoNotDelete.txt"
	set fileID to open for access file fileName with write permission
	write resultOfUserID to fileID
	close access fileID
	try

I'm not using Unicode at the moment. Frankly I didn't know if using it might make this issue go away.

The CR problem appeared when I use vi or pico. But when I "more" the file, it doesn't appear at all.
 

iMeowbot

macrumors G3
Aug 30, 2003
8,634
0
Yay. The similarities between AppleScript and INTERCAL are too many to be mere coincidence, aren't they?
 

yellow

Moderator emeritus
Original poster
Oct 21, 2003
16,018
6
Portland, OR
INTERCAL (wikipedia to the resuce)... it strikes me as a programming language as written by Terry Pratchett! :D

Or perhaps Doug Adams.. but I just finished re-re-reading a TP book, so I have Pratchett on the brain.
Hopefully this Cipro will clear that up.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.