Repair DB's for a user one liner / cpanel server.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Repair DB's for a user one liner / cpanel server.
# 1  
Old 09-22-2010
Repair DB's for a user one liner / cpanel server.

Hello,

I could use a little help with the command line part of this. I've got it to sorta work if I use this
Code:
`gawk -F"/"'{ print $3 }'`

I've also tried
Code:
`pwd|cut -d/ -f3`

with no luck. Is this possible to do? I'm basically doing this to copy the users domain, then paste that into the command.

I could not get
Code:
`/scripts/whoowns (pastes in domain with ahk)`

to print the username as part of the username_% either.


What the full command is currently:

Code:
for i in `mysqlshow `/scripts/whoowns (pastes in domain with ahk)`_%|sed '1,4d'|sed '$d'|awk '{ print $2 }'` ; do mysqlcheck -rf $i; done

# 2  
Old 09-22-2010
first - please confirm you are sanitizing the user input.

second - you may want to create a production level script with error checking, logging etc .. rather then a one liner.

can you provide sample input and expected output?
# 3  
Old 09-22-2010
My apologies on not being familiar with security practices as far as sanitizing the input, this would just be run as root and something I'd run on a server with multiple users.

When working it goes..

$ for i in `mysqlshow user_%|sed '1,4d'|sed '$d'|awk '{ print $2 }'` ; do mysqlcheck -rf $i; done
user_jmla1.jos_banner OK
user_jmla1.jos_bannerclient OK
user_jmla1.jos_bannertrack OK

and so on.

A script would be nice, then it could be run on any production server like domain/script|bash though for now this would just be a nice simple one liner.
# 4  
Old 09-22-2010
i strongly suggest you become familar. running scripts from root from user supplied data without sanitizing data is a huge security risk. besides that shouldnt these commands really be run from the mysql user account?

I am still not sure what your asking for. you posted an example run but what variables are you feeding it.
# 5  
Old 09-22-2010
Variables?

mysqlshow user_%|sed '1,4d'|sed '$d'|awk '{ print $2 }'
prints out for example:

user_jmla1
user_wp1
user_zen1

going through a for loop to run mysqlcheck -rf.

for i in `that DB printout`; do mysqlcheck -rf $i; done

I'm just wondering if there is a way I can get the username within that. rather than having to type it out.

mysqlshow `(something to print the username that works)`_%|sed '1,4d'|sed '$d'|awk '{ print $2 }'
# 6  
Old 09-22-2010
Does this work for you?

Code:
mysqlshow user_%|awk -F_ '{print $2}'

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script to take cPanel backup in batches

I'm trying to resolve the below scenario by writing bash script. On my managed linux server I have about 30 accounts and there is not enough space to generate full 30 accounts backup in one go and transfer it via SFTP to my Backup Synology Server. What I'm thinking of doing is breaking the... (3 Replies)
Discussion started by: humble_learner
3 Replies

2. Shell Programming and Scripting

How to scp File from root user in one server to say crt user in another server and avoid password?

Can someone help in writing some script through which I can transfer file (scp) from root user in abc server to crt user in hfg server and can give the crt user password in script itself so that it doesn't prompt me every time for password (4 Replies)
Discussion started by: Moon1234
4 Replies

3. UNIX for Dummies Questions & Answers

How to get cpanel backup data in rescue mode?

How to get cpanel backup data in rescue mode? Server OS 6.3 minimal with cPanel /dev/sdb1 is main partition root@rescue ~ # fdisk -l Anyone can help Thank you (0 Replies)
Discussion started by: jaydul
0 Replies

4. Shell Programming and Scripting

delete ftp accounts created in cpanel

i want to delete the extra ftp accounts that are created in cpanel e.g., when you go to cpanel->ftp accounts, any that are not there by default how can i do this via commandline? i am looping through the users on the server where is this info stored? also - how can the password of an... (0 Replies)
Discussion started by: vanessafan99
0 Replies

5. UNIX for Advanced & Expert Users

cpanel issue

How to disable mod_setenvif module in apache durin run time in cpanel servers. Please help me (0 Replies)
Discussion started by: pssooraj72
0 Replies

6. AIX

passwordless entry using ssh from one user to a different user on the same server

Hi, We have a requirement to do passwordless entry from one user to a different user on the same AIX server using ssh keys. Can some one help me with this? Thanks in advance, Panditt (3 Replies)
Discussion started by: deshaipet
3 Replies

7. Shell Programming and Scripting

Search & Replace regex Perl one liner to AWK one liner

Thanks for giving your time and effort to answer questions and helping newbies like me understand awk. I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk. Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Discussion started by: verge
9 Replies

8. Shell Programming and Scripting

script for cpanel

Hello, I'm Have 1 Question abut if i need to run another script in my bash script by example /scripts/killacct this script for cpanel but when i try to execute this command /scripts/killacct username he ask me yes or no any idea to answer on this question with yes in my bash script I'm... (2 Replies)
Discussion started by: LinuxCommandos
2 Replies

9. UNIX for Advanced & Expert Users

Server load (Unix/Linux, Redhat, CPanel)

Hello, I'm facing a big problem with my hosting server (Dual Xeon 2.4GHz), I'm having a load in the CPU usage and the memory (maybe it's related) ALSO mySQL: Server Load 5.34 (2 cpus) (to 22 sometime) Memory Used 68.4 % (to 70% sometime) When I go to 'CPU/Memory/MySQL Usage' I found: ... (3 Replies)
Discussion started by: Kh@lid
3 Replies
Login or Register to Ask a Question