How do your check for existing .pid before starting wamp? - mysql

I'm looking for a way to be sure it is not already running on some other machine before starting it.
The best way I've figured out is to check for an existing .pid in the MySQL folder.
The easiest thing would be to modify the shortcut but I don't think that's possible afaik.
So I need to do a couple of things.
figure out where MySQL is stored
check for the existence of a .pid file and if found the file throw an error stating so with the name of the file MINUS the extension to give them a hint what machine is be running it.
if not exist then go ahead and start wamp like it normally would with the shortcut.
DONE.
If necessary we can ask the user ONCE where wamp is stored then it's simply at %wamp%\bin\mysql
I tried this script but it doesn't do it properly, it's opening 2 cmd windows and just throwing a pause.
Thanks
Bear
#echo off
cd "C:\google_drive\server\wamp64"
forfiles /p bin\mysql\ /m *.pid /s /c "cmd /c goto error"
start wampmanager.exe
exit
:error
echo I'm sorry, Mysql is already running so I can't start WAMP for you. Shutdown WAMP on #FNAME before running again."
pause

You can check the existence of a file with:
if exist "C:\google_drive\server\wamp64\bin\mysql\*.pid
But per your description, I guess, there may be more than one .pid file, so there is a better choice:
setlocal enabledelayedexpansion
set "running="
for %%a in ("C:\google_drive\server\wamp64\bin\mysql\*.pid") do set "running=!running! %%~na,"
if "%running%" neq "" (
echo I'm sorry, Mysql is already running so I can't start WAMP for you.
echo Shutdown WAMP on: %running% before running again.
pause
goto :eof
)
start wampmanager.exe

Related

PHP Mysql laravel 5.4 terminal issue

i am new to laravel i just figured out how to install composer laravel etc etc on my local machine MAMP on windows , Now i am confuse with the command on terminal which is
C:\project>mysql -uroot -proot
'mysql' is not recognized as an internal or external command,
operable program or batch file.
How can i fix this ?
setting Environment will solve the issue
Go to Control Panel -> System -> Advanced
Click - Environment Variables
Go to- System Variables find PATH and click on it.
add the path to your mysql\bin folder to the end paths. (ex: E:\xampp\mysql\bin) and add ; end of the line
Close all the command prompts you opens.
Re open and try it.
Setting the PATH to point to the MYSQL bin folder is normally the first thought, but I find that dangerous as things get left lying around when you change software.
I normally create a little batch file in the projects folder or in a folder that it already on your PATH, like this
mysqlpath.cmd
echo off
PATH=C:\mamp\path\to\the\mysql\bin;%PATH%
mysql -v
The mysql -v will output the mysql version number but it is a handy way of knowing that the correct folder has been added to the PATH. This adds the folder to the PATH but only for the life of the command window.
Then just run this from any command window when you want to use MYSQL from the command line
> phppath
You may also like to create one for PHP as well
phppath.cmd
echo off
PATH=C:\mamp\path\to\the\php\;%PATH%
php -v

Silent Uninstall Chrome Isn't Working

I'm creating a batch to automate setting up new computers and one of the programs is AVAST. When I install avast silently, it installs chrome as well. Chrome isn't a program that I'm wanting to put on and it seems there is no workaround. So now I'm trying to make it uninstall chrome silently after AVAST but it just opens a new cmd window instead of running the exe.
#echo off
CD /d "C:\Program Files (x86)\Google\Chrome\Application"
for /r %%f IN (setup.ex?) DO (
START /WAIT "%%f --uninstall --force-uninstall --multi-install --chrome --system-level"
)
pause
Moving the end quotation to the end of %%f just gives an error that --uninstall isn't an existing file.
I've tried this on multiple PC's.
Not sure your still looking for an answer, but I was able to make your batch work.
CD /d "C:\Program Files (x86)\Google\Chrome\Application"
for /r %%f IN (setup.ex?) DO (
"%%f" --uninstall --force-uninstall --multi-install --chrome --system-level
)
This may not be the answer... but it's too long for a comment! Are you certain that you must instqall Chrome? How did you install AVAST? Can we see the command line? If you used some kind of answer file perhaps it can be modified or perhaps you can pass arguments to your install command. Try doing the command with /? to see if you get choices. According to this you do have a choice. https://blog.avast.com/tag/google-chrome/
"As we get close to our launch date for our new Avast! Free Antivirus, version 5 we have an exciting new agreement with Google to announce. Starting in mid-November, we will be giving our new users an option to install Google Chrome when installing Avast. And to be clear here since I think some readers were reading too much into this entry. We are not forcing Chrome on users. It is entirely up to the user–to download/install is entirely up to the user and nothing is hidden."

bash.exe: warning: could not find /tmp, please create

why my sublime text giving me warning: bash.exe: warning: could not find /tmp, please create
although it is building and running the code correctly.
Please help me just got irritated by seeing this warning.
I have searched the whole web but i couldn't find any solution
This error message is misleading. At least for me it did not solve the problem after creating /tmp directory. Problem was solved after I killed sh.exe.
To piggyback on Kode Charlie's answer:
Open Start Menu
Type "cmd"
Press Enter
type "bash"
Press Enter
type "mkdir /tmp"
Press Enter
Close the command prompt window
Solved the error for me in Sublime Text 2.
In my case I am using windows. My solution was:
Find "bash.exe" at git folder installation - default is
"C:\Program Files\Git\bin";
Double click bash.exe;
At the command line type: mkdir /tmp
And done.
Try opening a bash-shell, and then:
$ mkdir /tmp
See if that makes the warning go away.
If you're using Git for Windows, just create the directory:
C:\Program Files\Git\tmp
Rebooting Windows fixed it for me.
To add to Necros answer, Not all windows 10 builds even come with bash
https://www.windowscentral.com/how-install-bash-shell-command-line-windows-10
Seems like a harmless error that can be ignored. It also occurs when your /tmp/ is a mount to %TEMP%
C:\Program Files\Git\usr\bin>.\env bash
bash.exe: warning: could not find /tmp, please create!
bash: __git_ps1: command not found
/cygdrive/c/Program Files/Git/usr/bin
So for instance, you may get this error if you have a bash script with a shebang
#!/usr/bin/env bash
Although not SublimeText related, I had this warning when running make.exe from a "Git Bash" environment.
The cause ? Due to search path ordering, a different sh.exe was being executed. (I.e. not in /usr/bin)
$ sh
$ ps -s
4348 pty1 09:48:42 /usr/bin/ps
4836 pty1 09:48:40 /c/Users/Nigel/bin/sh
4400 pty1 09:48:36 /usr/bin/bash
4596 ? 09:48:36 /usr/bin/mintty
4808 ? 09:36:14 /usr/bin/mintty
512 pty0 09:36:14 /usr/bin/bash
After deleting the unwanted left-over C:\Users\Nigel\bin\sh.exe; the warning no longer appears.

Control-M job not ending after .bat finishes

I have a .bat file that maps a network drive, runs an MS Access program then deletes the mapped drive and exits. When I run it through Control-M the .bat runs and finishes but the job in Control-M never ends. I have tried multiple things to end the file to send Control-M an exit code but nothing seems to be working. Below is the code:
#echo off
net use w: [path]
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "Y:\MSAccess.mdb"
net use w: /delete
After this code I have tried the following commands:
exit
_exit 0
timeout /T 10
No matter what I try Control-M never seems to know that the job has finished. The sysout from Control-M also does not show any kind of exit code being sent back.
Control-M is probably waiting for all the processes started under it to exit before exiting the job itself. In your case, MSACCESS is still running when the end of the BAT is reached, so it prevents Control-M job to finish.
If you have your BAT to wait for MSACCESS to finish,
net use w: [path]
start /b /wait "" "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "Y:\MSAccess.mdb"
net use w: /delete
this might alleviate (at least stetically) your problem
After some more testing and investigation the issue was happening earlier in the .bat. The MS Access database was never being opened and run. Therefore since it was never starting it was never ending or sending an error code. I am researching why the MS Access database was not running now, which may lead to another question.
I had the same problem. I resolved my problem by adding the following at the end of the bat file:
exit /b %errorlevel%
For Windows batch scrips, add exit /b %errorlevel% at the end of file. This will help to find script has processed properly and control job will end/endnotok.

How to install MySQL on Leopard, Mac OS X 10.5?

I followed this tutorial to the very end, then found out it didn't work right. I think I have everything installed but when I type
mysql -uroot
I only get
-bash: mysql: command not found
Note: I did not skip the "Setting the Path" step. Upon running this command for the first time:
mate ~/.bash_login
This brought up an empty file. So I added this line:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
I saved the file, closed TextMate, executed the following command:
. ~/.bash_login
...and continued with the tutorial. Based on your suggestions, I thought maybe the file didn't actually get saved. So I ran the following command to bring up the file again:
mate ~/.bash_login
...yet the contents of the file were as they should be.
Any suggestions?
You probably don't have the mysql binaries in your path.
The link you posted has a section on setting the path, titled "Setting the Path Do not skip this step! Most everything else will fail if you do."
EDIT: As debugging steps, try:
First launching a new terminal window. Does it run now?
Typing "echo $PATH" at the prompt. Does the path show up correctly as you've typed it in bash_profile?
Running it the long way: /usr/local/mysql/bin/mysql -u root
Does the application run?
Did you follow the step that says
Setting the Path
Do not skip this step! Most everything
else will fail if you do.
Did you close your terminal window and re-open it afterwards?
Update:
What does "which mysql" say? Does "ls /usr/local/mysql/bin" say?
Two things:
Try editing ~/.profile (rather than ~/.bash_profile or ~/.bash_login).
You may find it easier to use the native Mac style .dmg installer directly from Sun.
One nice thing about the dmg installer is that it automagically sets up symlinks to /usr/local/mysql (which means less - or no - fiddling with your $PATH).
Another option would be to use MAMP.
It has Apache, PHP and MySQL packaged with no further setup necessary.
MySQL is usually put in /usr/local/mysql/bin/
You need to add this to your PATH, you can do this by adding the follwoing lines to your .bash_profile
PATH=$PATH:/usr/local/mysql/bin/
export PATH
The .bash_profile file is located in the root of your username directory.
Make sure you restart your Terminal for the setting to take affect.
And if you're not a command-line person, I highly recommend you also install the MySQL Preference Pane to start/stop the server and install Sequel Pro to create databases and run queries.
ftp://ftp.mysql.com/pub/mysql/download/gui-tools/MySQL.prefPane-leopardfix.zip
http://www.sequelpro.com/