Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launching a server-side executable through a stored procedure

Status
Not open for further replies.

encore20

Programmer
Jul 9, 2012
2
US
Hi,

I'm new to FoxPro and I was wondering is it possible to launch an executable that is located on a server from a FoxPro stored procedure. The exe is located on the server, but I want to execute from within a FoxPro program. Once executed, the program should run on the server and not the client. Is this possible? I have tried placing a Do prog command on a stored procedure, but it runs on the client side and not the server side. Below is the stored procedure I am attempting to use. I first switch to the server directory and then I call a Do statement.

Procedure executeprog

cd('server path')
Do prog

end proc


Like I said, I am new to FoxPro so this may be way off, any help would be greatly appreciated!
 
Hi Encore, and welcome to the forum.

To answer your question, it's necessary to know what kind of server you are talking about. The fact that you mentioned a stored procedure suggests that it is a database server (like SQL Server or Oracle)? Is that right?

Or do you simply mean a file server? Or perhaps a web server?

What you are trying to achieve should certainly be possible, but let's clarify this point before sending you down the wrong road.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Hi Mike,

Thanks for the reply!

You are correct, I am using a database server(SQL Server 2008). I found an example of running a stored procedure using SQLEXEC but it would not run an executable server-side so I was trying to find a way, if possible, to use only FoxPro commands to get the job done.
 
If you want to start an exe from a stored procedure in an SQL Server, that's not a foxpro question, it would rather be a question for an SQL Server forum. I'm using SQL Server, too, but mainly for SQL, not for such unusual approaches. What should the exe do on the server?

One general idea, if you want to run something server side, is to start a service, like SQL Server does, and be able to make requests to that service. There is a possibility to create a service from any exe via SrvAny, google it. As an alternative to creating your own service, IIS would be a good approach for that. Many solutions bringing foxpro to the web go that route, eg AFP, ActiveVFP, FoxWeb, and many more.

The second possibility is to start a COM server, an OLE class of eg a DLL or an EXE via CREATEOBJECTEX(). You need a COM Server and privileges for such remote executions.

And the third possibility is to use CreateProcessWithLogonW or CreateProcessAsUser via Windows API.

If your question mainly is about an analogon to SQL Server stored procs in foxpro dbc stored procs, then rather forget about it. Foxpro is no client/server database in that sense. There once was but that's gone, nobody used it. While that could help performance for complex queries, you get the overhead to return data to the client somehow, if we talk about sql queries. It's nice to have a fast query running local on the server, but then what do you do with a cursor in a datasession of the server process, you need to turn it into something transportable, eg store it into a seperate dbf file, or turn it to xml to return it as a string, and then the client needs to load this or that into it's cursor.

You have rushmore optimisation and indexes to speed up dbf access to dbfs stored in a lan drive and that works fine for the past two to three decades.

Bye, Olaf.
 
You use the xp_cmdshell() function to execute an executable from within T-SQL. You can call it directly from VFP, using SQLEXEC(). Or you can embed it in a stored procedure, and execute that from VFP (by passing an EXEC command to SQLEXEC()).

There are a number of security issues with xp_cmdshell(). Also, it is not enabled by default. The Help topic in Books Online has the relevant information.

If you have any difficulties with the function, you might do better by asking in the "Microsoft SQL Server: Programming" forum here on Tek Tips. (But ask here if you have an issue with SQLEXEC() or other Foxpro-related stuff.)

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top