mjinxed
asked on
Create script that includes password and some commands - can I do it?
Hello,
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 "go.pl" 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 go.pl 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
Open WS_FTP
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 go.pl
go.pl contents------------------ ---------- ---------- ------
#!/bin/sh
cp ORDERS.txt /ORDERS.txt
mysql -u root -p db < /home/user/build.txt
-------------------------- ---------- ---------- ---------- ----
type root password
build.txt contents------------------ ---------- ---------- --
use db;
TRUNCATE TABLE `pages`;
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
rinse
repeat
MJL
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 "go.pl" 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 go.pl 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
Open WS_FTP
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 go.pl
go.pl contents------------------
#!/bin/sh
cp ORDERS.txt /ORDERS.txt
mysql -u root -p db < /home/user/build.txt
--------------------------
type root password
build.txt contents------------------
use db;
TRUNCATE TABLE `pages`;
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
rinse
repeat
MJL
I just don't see why this question is in the PHP section...you *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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.