Solved

mySQL command like MSSQL EXEC?

Posted on 2010-08-12
8
661 Views
Last Modified: 2012-05-10
In MSSQL, you have access to the command line using the EXEC xp_cmdshell 'DOS command goes here'.

Is there anything like this using mySQL to run a PHP script?

0
Comment
Question by:EddieShipman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 31

Expert Comment

by:Frosty555
ID: 33423112
mysql has a CLI, just like mssql. It's in the mysql BIN folder, and it's just the executable file "mysql.exe"

You execute mysql queries using it, though, not PHP.

PHP has it's own command line executable which will execute a PHP page though, PHP.EXE.
0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 33423114
I don't believe there is for security reasons.
0
 
LVL 31

Expert Comment

by:Frosty555
ID: 33423237
I think I misunderstood the question. |Sorry about that.

PHP has an exec() function for this purpose (provided your server has it enabled) - does that not work for you?

http://php.net/manual/en/function.exec.php

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 17

Accepted Solution

by:
jrm213jrm213 earned 500 total points
ID: 33423278
I think he means in a MS SQL Stored Procedure you can use the EXEC command to execute code via the DOS Command Shell, and wants to know if there is similar functionality in MySQL, which there isn't as far as I know.
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 33424401
yes, jrm213jrm213, exactly what I need. I don't think the others quite understood. ;-)

I'm not saying MSSQL is any more secure than mySQL, BTW, but if it's for security reasons, why would MSSQL have something like it?

The whole reason behind this is that I have a stored procedure where I need to actually download a file and store the file name in the database. This is for a vendor file import routine for my e-commerce solution. The images are links and I can do it in PHP but I *NEED* to do it in my stored proc.

I have a PHP script to do the import but have converted the whole thing to mySQL functions and stored procedures to speed up the process and that is the last thing on the agenda, importing the image.

0
 
LVL 25

Expert Comment

by:Tomas Helgi Johannsson
ID: 33427785
                Hi!

Here are some PHP MySQL procedure examples
http://www.java2s.com/Code/SQL/Procedure-Function/CallingastoredprocedureinPHPanddealwiththeresult.htm
http://www.java2s.com/Code/SQL/Procedure-Function/ReturnthefilesizebyusingtheLOADFILEfunction.htm
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_load-file

which gives you an idea on how to call procedure and insert a image/file into blob using LOAD_FILE function.

Regards,
   Tomas Helgi
0
 
LVL 25

Expert Comment

by:Tomas Helgi Johannsson
ID: 33427840
       Hi!

One other thing. You would have to download the images  from a remote website to your site temporarily (to a tmp directory) using PHP and then issue a
call to the MySQL procedure to store the file to db.

Regards,
    Tomas Helgi
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 33428338
I cannot do that without some kind of EXEC functionality because my procedure iterates through the records of the import file that was loaded into a table using LOAD DATA INFILE.
Since the file must already reside on the host, LOAD_FILE ain't gonna do that for me.

I don't need to load them in a BLOB field because the local filenames are stored in a table,
like it should be .vs in a BLOB.

BTW, I already know how to call the stored proc from PHP.

Since this seems undoable, I may just do the images after the initial data load.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MYSQL database problem within Coldfusion 2016 environment 12 57
MySQL Query Using Up Memory 6 52
Inserting data into database 10 46
Where on a calculated field 1 31
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question