DanBrill Posted December 16, 2003 Posted December 16, 2003 Hey, This is probably a stupid question, but here goes.... I have a script that I only want to run on the host machine. status(CurrentHostName) tells me who the current host is. But how do I know if a given computer is the host? Status(CurrentUserName) gives the name of the current user, but not the name of his or her computer, so this won't work. Do I have to parse it out from the status(CurrentFilePath) function? Thanks, Dan
Kundinger Posted December 16, 2003 Posted December 16, 2003 Hi Dan, Quick answer... Host is the FMP software & computer who opened a specific file first (in multi-user mode). Here are some other senarios... - If the file is on a FMP Server, the server is the host... because the file was opened by the server. - If the file is on a workstation (no filesharing on), then this workstation will be the host when a user opens the file. - If the file is on a FILE server share-point, the host is the first FMP software & computer to open it. An idea to limit script access... Use script steps that look at the user/group name... only certain users/groups can continue the script... others get a friendly error. This can be managed within the FMP Access Privileges or managed within a customized Access/Privileges/Permissions/Rights Log-On system. Hope this helps... Good Luck! Bob Kundinger [email protected]
DanBrill Posted December 16, 2003 Author Posted December 16, 2003 Hey Bob, Thanks for the response. The 3rd situation you describe is what I'm looking at. Unfortunately, your suggestion won't work for 2 reasons. First, I'm not really concerned with which user runs the script, but with which computer. It might be the right user on the wrong machine. Second, I'm using a custom security system, so all users are logged into FM with the 'no password' password and there are no groups. But as I thought about the problem a little more, I realized that I wasn't really concerned with which computer was the host, but with which computer is actually storing the file. I only want the script to run if it is on the machine that stores the file. It wouldn't necessarily be the host, but this would be the most common situation since hosting a file that resides on another machine tends to slow things down substantially. So what I am thinking at this point is something like this: if the file resides on the computer then CurrentFilePath is file://C:/Directory/File.fp5 but if it resides on another computer then CurrentFile path is file://ComputerName/Directory/File.fp5 so if middle(Status(CurrentFilePath),9,1) = ":" then run procedure else exit This should do the trick. Thanks for getting my brain into gear. Dan
Kundinger Posted December 16, 2003 Posted December 16, 2003 Dan, Sounds like you're on track to think this through... that's 'Learning FileMaker'! I've done my process (with specific user) through a Log-On system... it works good. I've never done what your looking at, but you seem to be going in the right direction. If not... thats how you learn a lot about FileMaker... go in different directions until you find the right path. Also... what is this script trying to do on a specific host? Archival/Backup? Later... Bob
DanBrill Posted December 16, 2003 Author Posted December 16, 2003 Hi Bob, To answer your last question first, its part of a script that pulls in data from QuickBooks via an xml import. Because of the way QuickBooks has its xml set up, the QuickBooks data file and the FM files have to be on the same drive. (They say they'll be fixing this in the next version of their xml specification so that files can be accessed across networks. But until then....) So I only want users that are on the machine that stores the QuickBooks and FM files to actually execute the import. The good news is that I've got it fixed. Here's how if [Middle(Status(CurrentFilePath),9,1)<>":"] Show Custom Dialog: [field value -- calc field "QuickBooks data must be imported by "& Middle(Status(CurrentFilePath),8, Position(Status(CurrentFilePath),"/",1,3)-8)&", the computer on which the Database is stored" exit script else [perform the rest of the script] In other words, if the file isn't stored locally (thus showing the ":"), give the error message which parses out the computer name from the path name. Thanks for your encouragement! Dan
Vaughan Posted December 16, 2003 Posted December 16, 2003 Dan The FM function you want is "Status (CurrentMultiUserStatus)" it'll tell you whether the file is single user, multi-user guest or mulit-user host. As for importing, I've just implemented a system where I gave the users a small, single-user file that lives on their local drive to perform the import (actually it was an XML export but the same applies).
Kundinger Posted December 16, 2003 Posted December 16, 2003 Dan, Looks good... you 'overcame'! Other idea... you could have the script look for the Quickbooks directory using a specific path name... if not found... error message... if found... PROCEED! In your script... seterror capture ON import(data.xml,"C:pathname") if error = ##
DanBrill Posted December 16, 2003 Author Posted December 16, 2003 Hi guys, Vaughn, that would have worked for my original question, but not for what I realized was the real question. The real question -- 'is the file open on the same computer it is stored on?', is different than 'is the file open on the machine that's hosting it?' Bob, that solution wouldn't work in this situation, because by the time I'm importing the xml, I'm too far into the script. (Before I import the xml I have to trigger the creation of the xml files through another process.) But its a good idea in general. Thanks again to both of you for your suggestions, Dan
Recommended Posts
This topic is 7651 days old. Please don't post here. Open a new topic instead.
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 accountSign in
Already have an account? Sign in here.
Sign In Now