Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) AsyncShell issue (Read 3792 times)
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
AsyncShell issue
Apr 3rd, 2005 at 8:47pm
Print Post Print Post  
I have been spending hours trying to make a single ASYNCHSHELL line run without success.

Original line called an executable directly with 3 parameters.  Kept getting message that file could not be found.    Then made a batch file to call the executable with %1-%3 for parameters.  Still had no success. 

To help diagnose, I reduced things to a batch file with one parameter passed in as %1.  No success. 

Made many variations with @CHR(34) and multiple variables and strings on all of the trials above, without success. 


Finally I tried @SHELL vs @ASYNCHSHELL for the batch file with the %1 and it works fine. 

If @ASYNCHSHELL does not have to pass a parameter, it runs the batch file with no problem, but "cannot find file" when a parameter is passed.

Code
Select All
var vOK as Int
var vSSPath as String
var vPArameter1 as String

vSSPath = "C:\Sesame\Utilities\SensibleSolutions\View.bat"
vParameter1 = @Database

//This line always fails, message that file cannot be found
vOK = @ASYNCHSHELL(vSSPath + " " + vParameter1)

//This line runs OK, (with black DOS box)
vOK = @SHELL(vSSPath + " " + vParameter1) 



I am too close to this right now, it is probably something really basic, but I am burnt out, need to walk away for a while.  While I am walking, perhaps someone else will see the obvious that I have missed ....

Any ideas on why @ASYNCHSHELL "cannot find file" ?

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: AsyncShell issue
Reply #1 - Apr 3rd, 2005 at 10:33pm
Print Post Print Post  
As far as I understand it, AsynchShell launches a program like a windows Icon would; you only need to specify the 'target' and, if windows has a program associated with that 'target', the program will launch automatically.

This example will launch the below text file in Notepad, becuase Notepad is associated to all .txt files.

var nn as int

nn = @AsyncShell("C:\programming.txt")


Hope this helps.

Steve

ps. I think you are a subscriber to Inside Sesame. There is a good article on using AsyncShell in the April edition (just released a few days ago)



  
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: AsyncShell issue
Reply #2 - Apr 4th, 2005 at 1:34am
Print Post Print Post  
Thanks Steve, but I am not working with an "associated" target file.  I am working directly with the executable and also passing in parameters.  More information about this can be found in the Programming Users Guide, pp 150-152.

And yes you are correct, I do get Inside Sesame, but the article does not help me out here.  The article does a good job of explaining how this will eliminate the DOS black box.  Which, if you see in my message above is coming up when  I use @SHELL, but using @ASYNCHSHELL instead hangs, because it "cannot locate file". 

What is even more frustrating is that the error message is very informative, it gives the EXACT names of the executable, and the parameters that I am trying to pass.  So I know that the variables are translating properly, but ASYNCHSHELL seems to be having trouble parsing the executable from the parameters.  It is like it is using the entire string as if is was one executable filename.

From what I can see, I have tried every combination of creating the string for execution, but I must have done something wrong.
.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: AsyncShell issue
Reply #3 - Apr 4th, 2005 at 3:49am
Print Post Print Post  
Quote:
I am working directly with the executable and also passing in parameters.


As I understand, @Asynchshell( ) does not work with parameter. It basically works with target and just executable file. If you have to work with executable and parameter, you have to use either @shell or make it into a script file which in turn will be only executable.

It seems like making batch file, that looks like executable but inside it contains parameters and it is somehow recognized by @asynchshell ( ) and that does not seem to work.

  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: AsyncShell issue
Reply #4 - Apr 4th, 2005 at 4:23am
Print Post Print Post  
Sesame Programming Guide has examples on bottom of Page 151 showing an executable with parameters and a batch file with parameters.  I have tried both with no success.

Documentation says it is same as @Shell, but does not need to wait for completion to return contol to Sesame.  No mention that parameters are not allowed, or that anything is different in syntax from @Shell.  And again, note that the @Shell versions are working with exact same syntax.

I suspect we will have to wait to hear from Mark and Erika on this one.

I am also looking to use @AsynchShell without using batch or wsf files.  If I need batch/wsf files then I have the distribution problems associated with network envirnoments,  Not insurmountalbe, but more problems to deal with and more expense for my clients.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: AsyncShell issue
Reply #5 - Apr 4th, 2005 at 4:37am
Print Post Print Post  
Bob, I looked at page 151 and 152. I do not see @asynchshell used with executable and parameters.

n = @AsynchShell("winword.exe")
Only executable

n = @AsynchShell("\Program Files\Microsoft Office\Office\winword.exe")
Only executable

n = @AsynchShell("C:\My Documents\MyArticle.doc")
Only Target

n = @AsynchShell(vDocsPath + vselectedDoc)
Only Target

Am I missing something?
  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: AsyncShell issue
Reply #6 - Apr 4th, 2005 at 5:00am
Print Post Print Post  
Hmmmm, you are giving me some good stuff here.  I did not see the distinction that you are pointing out re a "target" vs. an executable.  But reading the documentation seems to imply that both will work.

On page 151: Quote:
@AsynchShell() can simplify your programming when you need to launch external
programs and pass files or parameters to them.


And since you forced me to take a closer look at the examples, there are no @AsynchShell examples that pass parameters.  The only example are an executable and a target.  Looking at the details under the concatenation in the examples, I see that you are correct.  I took each added section as a parameter, and now see that they are a single string for a "target".

So what I need is an example of @Asynch calling an executable and passing parameters.  Is a batch file a "target"?  Batch files can take parameters, so this is an example of a target with parameters, not different from an executable with parameters.

Thanks again for pointing out that the examples were not what I thought they were.  It's good to have another set of eyes looking over your shoulder.
« Last Edit: Apr 4th, 2005 at 5:06pm by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: AsyncShell issue
Reply #7 - Apr 4th, 2005 at 12:06pm
Print Post Print Post  
Bob,

We just hand whatever you type to the operating system and say "run this".

What happens when you run the [b]exact[\b] command you are using with @AsynchShell using Windows Start/Run?

Instead of sending the command to @AsynchShell, send it to WriteLn, then copy-and-paste it into the the Start/Run box.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: AsyncShell issue
Reply #8 - Apr 4th, 2005 at 4:58pm
Print Post Print Post  
This is the Sesame code.
Code
Select All
vAction="C:\Sesame\Utilities\SensibleSolutions\SesameTableView.exe /DatabaseTableView=tblRooms /MaximizeView=1"
WriteLn(vAction)
vOK=@AsynchShell(vAction) 

When this is run, the cmd.exe black box stays open. Then I can manully close it with "X" in upper right corner.  Then I get message that fille cannot be located. When that window is closed, then control comes back to Sesame.

This was copied from the WriteLn and pasted into Run....
Code
Select All
C:\Sesame\Utilities\SensibleSolutions\SesameTableView.exe /DatabaseTableView=tblRooms /MaximizeView=1 

When that is executed, there is no sign at all of the cmd.exe black box. Control comes back to Sesame immediately.

An image of error message, also showing WriteLn results can be seen here.  At this point I suspect this may be happening because of the "=" character in the paramaters that are being passed.  The executable program takes its paramaters in the format /param1=value /param2=value, etc.  Could have from 0-10 parameter values.

But it is strange that running manually from command line and running from the Run window causes no problem.  So iit would seem that perhaps AsynchShell is using "=" as a delimiter before sending string on to Windows?

I should also mention that once the cmd.exe black box is closed and the error message is removed, that the executable does in fact run with its passed parameters.

I can also send the executable if you want to see this firsthand.   But will need special instructions to create proper environment, etc.

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: AsyncShell issue
Reply #9 - Apr 4th, 2005 at 5:33pm
Print Post Print Post  
Quote:
This was copied from the WriteLn and pasted into Run....
Code
Select All
C:\Sesame\Utilities\SensibleSolutions\SesameTableView.exe /DatabaseTableView=tblRooms /MaximizeView=1 

When that is executed, there is no sign at all of the cmd.exe black box. Control comes back to Sesame immediately.


When you do the above, does your exe run correctly?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: AsyncShell issue
Reply #10 - Apr 4th, 2005 at 5:54pm
Print Post Print Post  
Bob,

I've looked at the source code. @ASynchShell does not accept parameters. It can run an exe. It can pass a file (such as an html file or Word doc) to the operating system, which will then attempt to open it using the file associations.

If you want to do this, you can try using File I/O to write a bat file with the necessary parameters, then use @ASynchShell to run the bat file.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: AsyncShell issue
Reply #11 - Apr 4th, 2005 at 6:12pm
Print Post Print Post  
Quote:
If you want to do this, you can try using File I/O to write a bat file with the necessary parameters, then use @ASynchShell to run the bat file.


That sounds like a solution for me. Grin
It will eliminate the need to do a batch file distribution. 

Can check to see if batch file exists and create it if not.  And/or create it, use it, and delete it every time it runs (slower, but reduces files on end users machine)......  Aaargh!  Roll Eyes

And it looks like Bharat_Naik was correct in his analysis that it only accepts "targets" that have a systems association.  So, although it looked like a parameter being passed , it was really a target.

Strongly suggest that the manuals be modified to make it very clear that parameters cannot be passed.  See the quote from the earlier posting that I made. Perhaps provide an example of passing parameters by making a batch file with I/O.  I guess when I am done with this I will be able to provide you with the example.

I feel better knowing that it wasn't me, but that time is lost forever.  Learning can be expensive.

Thanks to Erika and Bharat_Naik for your help.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: AsyncShell issue
Reply #12 - Apr 4th, 2005 at 10:13pm
Print Post Print Post  
Well I made the batch file and used @AsynchShell() to run my executable.  The parameters needed are built into the batch file that is dynamically written.  The batch file is written, used with AsynchShell, and then deleted.  The code to do that follows here.  Error controls will be added in once basic commands are finalized.
Code
Select All
var vFileHandle1 as String
var vContent as String
var vShellFile as String

vContent = vAction	    //Defined above
vShellFile = "C:\Sesame\Utilities\SensibleSolutions\TableFullView.bat"

//Start Routine =======================
//Delete file if it exists, should have been deleted at last run
IF FileExists(vShellFile) THEN {
	    FileDelete(vShellFile)
	    }

//Create File =======================
vFileHandle1 = fileOpen(vShellFile)

//Write to File =======================
FileWriteLn(vFileHandle1,vContent)
FileClose(vFileHandle1)

//Run Utility File =====================
vOK=@AsynchShell(vShellFile)

//Delete File when done ===============
Loiter(500)	    //Need delay for batch file to run.  Del %0 will not work.
FileDelete(vShellFile) 



End result is that the executable is run with the necessary parameters.  No hanging, but.....two things now:

1.  I needed to add a Loiter() command to prevent deleting the batch file before it was done.  I guess I could use @Shell() so control to Sesame is delayed, but then I would see the black box........ But Wait!......
2.  The black cmd.exe box still comes up with the @AsynchShell()

Making progress in small steps.  So how do I make BlackBox go away?
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: AsyncShell issue
Reply #13 - Apr 5th, 2005 at 12:09pm
Print Post Print Post  
Quote:
Making progress in small steps.  So how do I make BlackBox go away?


You probably don't. The black box is the OS creating a command shell because it needs one to run your batch file. We have no control over this.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: AsyncShell issue
Reply #14 - Apr 5th, 2005 at 1:21pm
Print Post Print Post  
What if Windows Script was run instead of batch file? Would that make black box go away?  Since WSH or VSH (Visual Basic Script Host) file is also simple .txt file, it could be written using I/O. I believe windows script is run in pure Windows environment while batch file requires DOS Shell. Just a thought and I could be a way off on this one.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print