Create script that includes password and some commands - can I do it?


I'm working on a test server, not connected to network and not connected to Internet just doing some experimental work and I have to run these scripts like 100 times a day in my testing and tweaking and I want to automate some more of it. Right now I have a perl script named "" that has to be run as root but I can't log in as root so I have to log in as my user and then su root and then run that pulls some info from a txt file that dumpes into a MySQL DB. I wanna automate it ALL! Heck, if I could stick an icon on my desktop (Windows XP using PuTTY) that I could double click and it does all the logging in and SQL and everything and then self terminates when done, I'd be so happy I'd be a pig in mud. Here is what I do now - can someone help me simplify this repetitive process?

Generate data to ORDERS.ASC
Rename file to ORDERS.txt
Choose connection and click connect
Copy ORDERS.txt from my desktop to /home/user/ORDERS.txt
Close WS_FTP
Open Putty and choose my connection and click open
type user name
type password
type su root
type password
type perl contents--------------------------------------------

cp ORDERS.txt /ORDERS.txt
mysql -u root -p db < /home/user/build.txt


type root password

build.txt contents----------------------------------------

use db;


load data infile "/ORDERS.txt" into table pages fields terminated by ',' optionally enclosed by '"' lines terminated by '\n';

delete from pages where item_description like '%freight%';
delete from pages where item_description like '%applied tax%';

UPDATE `pages` SET `mod_date` = NOW();


type exit
type exit

generate new data

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

AmigoJackConnect With a Mentor Commented:
create file 1.bat

>>Generate data to ORDERS.ASC
whatever this means, make a command out of it and add it into 1.bat

>>Rename file to ORDERS.txt
add these lines into file 1.bat:
del orders.txt
ren orders.asc orders.txt

>>Open WS_FTP
>>Choose connection and click connect
>>Copy ORDERS.txt from my desktop to /home/user/ORDERS.txt
>>Close WS_FTP
add these lines into file 1.bat:
cd "\documents and settings\your_account\desktop"
ftp < 2.txt

create a file 2.txt which will include all commands executed via ftp and add these lines
cd /home/user
delete orders.txt
put orders.txt

>>Open Putty and choose my connection and click open
thats tricky, we need to use something non-gui, but ive never tested telnet. open up a commandline, type in "telnet" and use "help" along with the other commands to login into your host. the pattern is the same: create a file 3.txt and put in there all lines you need within the telnet-program, including the exit/quit-command. to your 1.bat you should add this line to execute telnet:
telnet < 3.txt

if you think youre overdone with this or want more answers, put a pointer question in "os / ms-dos" since .bat-programming relates to ms-dos :)
I just don't see why this question is in the PHP *could* probably rewrite all your scripts to execute as PHP files (assuming you have PHP on your test server), but if you need to develop a script that will automate Windows processes, that's more about writing a BAT file than a PHP file, I think...
All Courses

From novice to tech pro — start learning today.