Normal Topic So Close, Need Help With Redirect (Read 2822 times)
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
So Close, Need Help With Redirect
Jul 9th, 2018 at 2:48pm
Print Post Print Post  
Hi folks!

I'm writing a snippet of code to be a mass update to let folks know who is locking a record, and send a quick message to tell them to get out.  However, it's not working.  Code is below.

- the call of the IP works great
- the call of the User works great
- no matter what, I can't get the message to go through with @redirectprocess, or @shell, but the exact same line typed in a command prompt works -- why?

Thanks!


Code
Select All
stat vIPLookup as string
stat vIP as string
stat vIPUser as string
stat vIPCommand as string
stat vIPMessage as string
stat vMessage as string

vIPLookup = @PromptForUserInput("Which IP To Look Up?","192.168.2.181")
vIPCommand = @RedirectProcess("nslookup " + vIPLookup,"")
vIPUser = @RedirectPRocess("wmic.exe /node:" + vIPLookup + " computersystem get username","")
@MsgBox(vIPLookup,vIPUser,"")

if @instr(vIPCommand,"ERROR") < 1
{
	if @askuser("Message " + VIPUser + "?","","")
	{
		vIPMessage = @PromptForUserInput("Message?","")
		if vIPMessage <> ""
		{
			vIPCommand = "msg /server:" + vIPLookup + " * " + @chr(34) + vIPMessage + @chr(34)
			vIPCommand = @redirectprocess(vIPCommand,"")
			// vIPCommand = @Shell(vIPCommand)
		}
	}
}
 


  
Back to top
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: So Close, Need Help With Redirect
Reply #1 - Jul 18th, 2018 at 6:57pm
Print Post Print Post  
Hi guys ... no one?  Any one?
  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: So Close, Need Help With Redirect
Reply #2 - Jul 19th, 2018 at 1:33pm
Print Post Print Post  
Hey Blair,

This one was very tricky. Why you may ask? Well I'll bet my lunch money that your Windows OS is 64bit. Being that the current version of Sesame is 32bit when we make a system call(@Shell() or RedirectProcess()) the OS "knows" to launch what is essentially a 32bit command prompt. Now normally this isn't an issue but in this case the 32bit command prompt can't find msg.exe because Microsoft did not put the 32bit version of it in any directory that is in the PATH variable. Now you may be saying, but I can launch msg.exe from a command prompt. Yes, you can. You're launching the 64bit version of msg.exe with the 64bit command prompt. The solution however is rather simple(Just took a while to find....) we just need to tell Sesame the path to the 32bit msg.exe file. On a 64bit version of Windows(Except perhaps Home versions which may not have the executable), the path is "c:\Windows\sysnative\msg.exe" and on a 32bit Windows OS the path is "c:\Windows\System32\msg.exe".

So something like....
Code
Select All
Var vS as String
Var vPath as String

IF FileExists("c:\Windows\sysnative\msg.exe") Then
{
	vPath = "c:\Windows\sysnative\msg.exe"
}
Else
{
	vPath = "c:\Windows\System32\msg.exe"
}

vS = @RedirectProcess(vPath + " * 'My Message'", "") 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: So Close, Need Help With Redirect
Reply #3 - Jul 20th, 2018 at 2:26pm
Print Post Print Post  
Your lunch money is safe, it is a 64 bit computer (our terminals are all 64 bit Windows 10 Pro).  However I don't see a c:\windows\sysnative\ directory at all.

I do show a c:\windows\system32\ directory, with msg.exe in it, but no where else.  I did a quick recursive search for cmd.exe and found it in both c:\windows\system32\ and c:\windows\syswow64\ ...

So, how do I open a 64-bit shell and run a 32-bit msg.exe?
  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: So Close, Need Help With Redirect
Reply #4 - Jul 20th, 2018 at 2:53pm
Print Post Print Post  
BWETTLAUFER wrote on Jul 20th, 2018 at 2:26pm:
However I don't see a c:\windows\sysnative\ directory at all.


You won't see it through explorer. It's a virtual directory.

Try the code I posted in a single record Mass Update in say the sample database Customers.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: So Close, Need Help With Redirect
Reply #5 - Jul 20th, 2018 at 4:40pm
Print Post Print Post  
It worked!  Of course it just popped up a local message on my machine.  The next step would be testing it across the network.

I'm trying to run the following snippet of code, and it doesnt seem to work -- what would be the issue?

@redirectprocess(vPath + "msg * /server:192.168.2.181 +  @chr(34) + "test" + @chr(34),"")

  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: So Close, Need Help With Redirect
Reply #6 - Jul 20th, 2018 at 4:49pm
Print Post Print Post  
Looks like you are missing a quote mark(I'm assuming you modified your code so that vPath is just the directory and not the full path like in my code). Try:

Code
Select All
@redirectprocess(vPath + "msg * /server:192.168.2.181 " +  @chr(34) + "test" + @chr(34),"") 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: So Close, Need Help With Redirect
Reply #7 - Jul 20th, 2018 at 4:58pm
Print Post Print Post  
If you wanna try it outside of Sesame. You can launch a 32bit cmd prompt by running the cmd.exe that is in c:\Windows\SysWOW64. Just remember that you have to specify the full path to the correct msg.exe

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: So Close, Need Help With Redirect
Reply #8 - Jul 21st, 2018 at 3:55pm
Print Post Print Post  
Got it working!  Thanks!

Here's the full code, if anyone else wants to use this.

Code
Select All
stat vIPLookup as string
stat vIP as string
stat vIPUser as string
stat vIPCommand as string
stat vIPMessage as string
stat vMessage as string
stat vS as String
stat vPath as String

IF FileExists("c:\Windows\sysnative\msg.exe") Then
{
	vPath = "c:\Windows\sysnative\msg.exe"
}
Else
{
	vPath = "c:\Windows\System32\msg.exe"
}

vIPLookup = @PromptForUserInput("Which IP To Look Up?","192.168.2.181")
vIPCommand = @RedirectProcess("nslookup " + vIPLookup,"")
vIPUser = @RedirectPRocess("wmic.exe /node:" + vIPLookup + " computersystem get username","")
@MsgBox(vIPLookup,vIPUser,"")

if @instr(vIPCommand,"ERROR") < 1
{
	if @askuser("Message " + VIPUser + "?","","")
	{
		vIPMessage = @PromptForUserInput("Message?","")
		if vIPMessage <> ""
		{
			vIPCommand = @redirectprocess(vPath + " /server:" + vIPLookup + " * " + @chr(34) + vIPMessage + @chr(34),"")
		}
	}
}

 


  
Back to top
IP Logged