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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shell problem!!!!!!!!

Status
Not open for further replies.

jonybd

Programmer
Nov 3, 2002
166
BE
Asking 2nd time.

/////////////////////////////////////////////////////////
Backup & Recovery function not working can anybody tell why ? 1st two function working from module1 , but how to
let other 2 function work.
/////////////////////////////////////////////////////////

Global exePath As String
Global exeCmd As String
Global dBase As String

Global bPath As String
Global rPath As String

Function dRop()
Shell ("C:\mysql\bin\mysqladmin drop test")
'Shell (exePath & "\" & exeCmd & ".exe " & "-f drop " & dBase)
End Function

Function cReate()
Shell ("C:\mysql\bin\mysqladmin create test")
'Shell (exePath & "\" & exeCmd & ".exe " & "-f create " & dBase)
End Function

Function bAckup()
Shell "C:\mysql\bin\mysqldump --opt -u root test > f:\vbSql.sql", vbNormalFocus
'Shell (exePath & "\mysqldump.exe " & "--opt -u root " & dBase & " > " & bPath)
End Function

Function reCover()
Shell &quot;C:\mysql\bin\mysql -u root test < f:\inforev.sql&quot;
'Shell (exePath & &quot;\mysql.exe &quot; & &quot;-u root &quot; & dBase & &quot; < &quot; & rPath)
End Function
 
Not sure if I can help and I certainly have no knowledge of MySQL but...

You are using parentheses in the Shell command in the first 2 functions but not the others - could that be a factor (parentheses present in the commented code).

What error are you getting?

Have you tried typing the text (e.g. C:\mysql\bin\mysql -u root test < f:\inforev.sql) directly to the Command prompt?

 
You cannot use I/O redirection (< and >) when invoking programs using Shell function. This feature is supported only with command prompt.

Instead of invoking the command directly through shell, try invoking it by passing it as a command line argument to command.com program.

I mean,

[tt]Shell &quot;ipconfig.exe > ipconfig.txt&quot;[/tt]

will not work. But this will work.

[tt]Shell &quot;command.com /c ipconfig.exe > ipconfig.txt&quot;[/tt]

This invokes the command prompt and /c switch causes the following command line to be executed within the command.com environment successfully. The command.com automatically quits when the specified program (ipconfig) completes.

So try replacing the shell function calls;

Shell &quot;C:\mysql\bin\mysqldump --opt -u root test > f:\vbSql.sql&quot;
and
Shell &quot;C:\mysql\bin\mysql -u root test < f:\inforev.sql&quot;

respectively with;

Shell &quot;command.com /c C:\mysql\bin\mysqldump --opt -u root test > f:\vbSql.sql&quot;
and
Shell &quot;command.com /c C:\mysql\bin\mysql -u root test < f:\inforev.sql&quot;

I hope that it will work.
 
I m in WinXp:
I did all shell , winexec, shellexecute, shellexecuteEX
command.com

those are the following that wont work:
shell (&quot;command.com /c c:\mysql\bin\mysqldump.exe -u root database > f:\savenow.sql&quot;)

shell (&quot;c:\mysql\bin\mysqldump.exe -u root database > f:\savenow.sql&quot;)

================================================
this is working -> VB

shell (&quot;cmd.exe /c c:\mysql\bin\mysqldump.exe -u root database > f:\savenow.sql&quot;)

and c/c++ code

#include <stdio.h>
#include <conio.h>
#include <windows.h>
void main()
{
system(&quot;c:\\mysql\\bin\\mysqldump.exe -u root database > f:\\savenow.sql&quot;);
getch();
}

=================================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top