Forum Moderators: coopster

Message Too Old, No Replies

php script from the command line or a bash file

         

fb1800

9:14 pm on Dec 28, 2009 (gmt 0)

10+ Year Member



Hi,
I am new to php scripting.

I created a web application and now i need to test it with a big sample.

My objective is to create something like 100 fakes users into my SQL database on my server.

I would like to do that by just calling a bash, script, from the command line.

What i did uptonow is a php file where i connect to the database and insert all these fake users.

Unfortunately, i dont know how to call these php file from the command line and especially how to add parameters that are then used in the php file (i.e. : the number of profiles that need to be created).

I am working on Windows7.

Any ideas and tips are welcomed.

Thanks in advance.

Psychopsia

2:25 am on Dec 31, 2009 (gmt 0)

10+ Year Member



Hi!

If you will run the script for testing, why don't you call it from browser? (instead from commandline)

FourDegreez

2:37 am on Dec 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can call the php executable, passing the script file for execution. But consider calling the script using the lynx browser. It would look something like:

/usr/local/[path to]/lynx -dump http://www.example.com/yourscript.php?param1=100\&param2=50 >> /home/exampleuser/logfile.txt 2>&1

Psychopsia

2:45 am on Dec 31, 2009 (gmt 0)

10+ Year Member



FourDegreez: He said that is using Win7...

For a Linux dist, 'wget' can work too.

coopster

1:05 pm on Dec 31, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, fb1800.

Using PHP from the command line [php.net] should get you on track. With Windows, you will want to be careful as you escape from shell using the backslash [webmasterworld.com]

fb1800

4:27 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



Thanks for your help guys.
I did a script that can be called from the command line, it works fine. thx again