Bash Commands On Windows
Jun 5, 2007I asked around and found [url] and win-bash.exe on source forge.
View 1 RepliesI asked around and found [url] and win-bash.exe on source forge.
View 1 RepliesI opened up my VPS bash today and I saw a message like this:
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
..........................
..........................
You have a mail.
bash:~#
Now I am confused from where have I received a mail, and even if I have received it why doesn't it shows in Google Apps??
I have set the MX Entries correctly and when I sent a mail specifically to admin@mysite.com , I do get a mail in google apps.
Anyways where does this mail lie, how can I view this mail ?? I installed postfix as my mailing server.
I am running a CPanel VPS and wanted to see whats the actual ram stats. (My package have 512 MB ram)
The issue is, using two different methods, I am getting two different values.
Via SSH, free -m gives this
total used free shared buffers cached
Mem: 512 204 307 0 0 0
-/+ buffers/cache: 204 307
Swap: 0 0 0
and while running a script that I have found Here in WHT
Code:
#!/bin/bash
#
# Revised 02-Feb-2007: include kernel memory (kmemsize) in 'used' calculation
# and show percentages in output.
#
BEAN=`cat /proc/user_beancounters`
GUAR=`echo "$BEAN" | grep vmguar | awk '{ print $4;}'`
PRIV=`echo "$BEAN" | grep privvm | awk '{ print $2;}'`
KMEM=`echo "$BEAN" | grep kmem | awk '{ print $3;}'`
let TOTL=$GUAR/256
let KMMB=$KMEM/1048576
let PVMB=$PRIV/256
let USED=$KMMB+$PVMB
let FREE=$TOTL-$USED
if [ "$FREE" -gt "0" ]; then
let UPER=$USED*100/$TOTL
let FPER=100-$UPER
else
let UPER="100"
let FPER="0"
fi
echo "VPS Memory:"
echo " Total: $TOTL mb Used: $USED mb (${UPER}%) Free: $FREE mb (${FPER}%)"
It gives
Total: 512 mb Used: 482 mb (94%) Free: 30 mb (6%)
Why such huge difference??
Also "top" command shows
top - 02:44:04 up 1 day, 9:55, 2 users, load average: 1.35, 1.04, 0.94
Is that good for a a VPS with 512 RAM? (The site has extremely high traffic)
I've been reading through tutorials for setting up cron commands via cPanel, but everything I have tried does not work. What I need to do is simple - I just want to run a php file on my server once every 15 minutes.
View 1 Replies View RelatedWhen I log into my clients VPS via SSH and I get the following error...
login as: root
root@69.162.67.44's password:
Last login: Sun Jan 20 23:33:36 2008 from 122.167.25.31
-bash-3.1#
commands for cron job, i need to backup only 2 account backup in cron job one username is panther that a/c is in paretition "home" another a/c name logictec itz in partion "home2" for this two a/c only i need make cron job but there are in seprate partion can u help me in give the comman which can make backup in cronjob every one day
View 4 Replies View RelatedI am not familiar with shell scripting, so I'm asking for your help. I want to do
I need to batch convert all my videos so i used the command for particular folder media/ipod so i used
find /media/ipod -type f -exec mencoder {} -of mpeg -oac lavc -lavcopts acodec=mp2:abitrate=192 -af resample=44100:0:0 -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=50 -vf scale,harddup -ofps 25 -zoom -xy 176 -o {}.mpg ;
now i need to convert all my avi videos to 3gp for folder via batch convert.please help for this commands
I've just about got my mysqldump script ready,
Here is what it looks like:
Code:
#!/bin/sh
mysqldump -uusr -ppwd --opt db > /home/usr/dbs/1.sql
mysqldump -uusr -ppwd --opt db2 > /home/usr/dbs/2.sql
cd /home/usr/dbs
tar -zcvf sqldata.tgz *.sql
How would I make my finished gzipped file's filename to include the date?
Would I add any tags infront of sqldata.tgz *.sql?
Or would I have to run another command after the last line?
does anyone know how i would find out what version of apache server i have? i have root access.
View 5 Replies View RelatedI could use a bash script for a crontab that does a regular backup of my mysql database.
Unfortunately i can't employ one of the made-up backup scripts using mysqldump because i need to use mysqlhotcopy (that's because i need the raw data for a charset mess in mysql with some foreign languages not classifieds as utf8 .. long story), and i'm a total ignorant of perl and bash scripting.
The script (that will be recalled via cron) has to:remove all the .tar.gz files older than X days in the folder /xxx/backup, if the folder contains more than X tar.gz files
create a folder /xxx/backup/$todaydate call the command "mysqlhotcopy --bla -bla -bla " that will copy the dbase in the previously created /xxx/backup/$todaydate folder
at the end of the previous operation (if successful) compress the $todaydate folder in a $todaydate-sqlbackup.tar.gz file at the end of the previous operation (if successful) delete the uncompressed folder. launch the "rsync -bla -bla" command to syncronize this folder with a remote server I thought it will be something like a 10lines script, and i'll be glad to hand you a couple of virtual beers (via paypal ) as a thank you sign, but if the script is not trivial and you're willing to help anyhow, of course i'm willing to pay more.
apache 11421 0.0 0.3 2704 1712 ? Ss Oct09 4:35 bash
apache 11625 0.0 0.1 1912 884 ? Ss Oct09 1:12 bash
apache 14454 0.0 0.0 1764 128 ? Ss Oct17 0:00 /usr/sbin/apache
apache 15216 0.0 0.2 2308 1356 ? Ss Nov10 1:58 bash
apache 19597 0.0 0.2 2308 1336 ? Ss Nov10 1:50 bash
apache 22164 0.0 0.3 2704 1772 ? Ss Oct11 1:11 bash
I stopped apache but can see these when i do ps aux.
I'm having a problem with litespeed and apache, every time when I reboot the server listespeed and apache(both) are started and the server uses apache. I configured litespeed to use a conf file of apache so I can't remove just apache. I need a way when I restart the server litespeed is started and apache is stoped
2nd problem. how to make this in a batch script
The script will backup a directory every month and I need in every backup get a date like this directoryname-date(day/month/year)
Quick IPTables Commands
List: iptables -L -n | grep <IP Address>
Remove: iptables -D INPUT -s <IP 1> -d <IP 2> -j DROP
Insert: iptables -I INPUT -s <IP> -j DROP
Flush: iptables -F
Remove: iptables -D OUTPUT -s 0.0.0.0/0 -d 66.93.33.185 -j DROP
netstat -nap | grep :80 | wc –l (shows # of connections to HTTP)
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort –n (shows total connections per IP, if more than 100 block)
Code:
-rw-r--r-- 1 root root 975 Dec 22 2006 .bash_profile
root@server [~]# rm -f .bash_profile
rm: cannot remove `.bash_profile': Operation not permitted
root@server [~]# chmod +t .bash_profile
chmod: changing permissions of `.bash_profile': Operation not permitted
I simply wanted to modify something within the file but I keep getting permission errors. I'm logged in as root.
I am currently trying to create a bash script which I will run off a loop with a sleep interval that will query tcpdump (udp packets only) on a network interface, and is looking for length 10 packets.
So far so good, not that hard to code I know (Already made it / coded it this far perfectly). Now here is the tricky part, I only want the bash script to identify IP's that have sent over 15 packets with the length of 10. (This is the part that I can't seem to find a way to code).
I was thinking, from the output maybe to calculate the number of lines with the same equal IP's.
Once this script identifies that, it will automatically run a command which I have set. (Quite easy, and I can do this).
I am looking for someone to help me with this. It is a fairly simple and quick job (editing the script I have at the moment). I am willing to also pay (if needed) an amount for this to be completed too. Obvieusly not that much, but still something I am sure we can work out.
It may be useful to someone, sometimes the queded mail list gets gigantic because of some spammer and other emails that aren't spam could get deleted when using cPanel to control it.
The better solution would obviously be to prevent spammers of sending all those mails, if you know a better solution on cPanel 11 please share it with me.
==== REMOVE MAILS BY ID ====
/usr/sbin/exim -v -Mrm (MAIL ID HERE)
==== LIST QUEDED MAILS ====
/usr/sbin/exim -bp
==== OUTPUT NUMBER OF QUEDED MAILS ====
/usr/sbin/exim -bpc
==== DELETE FROZEN MAILS ====
/usr/sbin/exim -bp | awk '$6~"frozen" { print $3 }' | xargs exim -Mrm
==== DELIVER FORCEFULLY EMAILS ====
/usr/sbin/exim -qff -v -C /etc/exim.conf &
==== FREEZE MAILS FROM SENDER ====
/usr/sbin/exiqgrep -i -f (MAIL ADDRESS HERE) | xargs exim -Mf
==== REMOVE MAILS FROM SENDER ====
/usr/sbin/exiqgrep -i -f (MAIL ADDRESS HERE) | xargs exim -Mrm
somebody to write a very simple bash script to me , which will help me to "wget" some text files!
i want to do the following:
wget [url]
X changes for evey folder (main group)
Y will change for every file in the folder.
eg:
[url]
[url]
[url]
the next group:
[url]
[url]
[url]
The X value range [1-100]
the Y value range [1-13]
Sometimes if I tried to use rm to remove too many files I got this:
-bash: /bin/rm: Argument list too long
I think there was a workaround, like ls and then piping the result to rm, but I forget.
I need to make a bash script, when I run it ./script.sh it needs to vivit a website - [url]/something.php where something.php has some function, e.g for emails, so when someone visit something.php it sends email to my email address. I just need a way to visit it via bash script
View 10 Replies View RelatedI am trying to automate the installation of YUM, cPanel/WHM and CSF.
I have written a script that works perfectly all the way down to installing CSF...
It gives me the following error when moving onto the CSF installation;
--05:03:37-- [url]
Resolving www.configserver.com... 85.13.195.235
Connecting to www.configserver.com|85.13.195.235|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 433358 (423K) [application/x-tar]
Saving to: `csf.tgz'
100%[=======================================>] 433,358 338K/s in 1.3s
05:03:39 (338 KB/s) - `csf.tgz' saved [433358/433358]
--05:03:39-- http://%0D/
Resolving 15... failed: Name or service not known.
FINISHED --05:03:39--
Downloaded: 1 files, 423K in 1.3s (338 KB/s)
tar:
: Not found in archive
tar: Error exit delayed from previous errors
./cPanelServer.sh: line 9: cd: csf: No such file or directory
sh: install.sh: No such file or directory
./cPanelServer.sh: line 13: unexpected EOF while looking for matching `"'
./cPanelServer.sh: line 18: syntax error: unexpected end of file
Script Contents;
Code:
./yum.sh
cd /home
wget layer1.cpanel.net/latest
sh latest
cd /
rm -fv csf.tgz
wget [url]
tar -xzf csf.tgz
cd /csf
sh install.sh
echo -n "TESTING = "1"
read word
sed "s/$word/TESTING = "0"/g" /etc/file.conf > /etc/file.conf.new
mv /etc/file.conf.new /etc/file.conf
service csf restart
done
It's seems the script is having issues extracting "csf.tgz", but I have no clue.
TBH, this is my first ever script and I'm surprised any of it works!
im trying to write a script interfacing to WHM again via remote access key. What I want to achieve is to remove an ip from iptables. using PHP script (CURL), any thoughts on how i can remove an ip from iptables? I know the ssh command how to do it but i dont know if it will work via a PHP (CURL) script connecting to WHM via remote access key.
View 1 Replies View Relatedmy VPS provided didn't enable a lot of modules and that's why I can use a firewall(csf or apf) and dos deflate script
I need a simple script for it.
First,it has to call this:
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
then there will be something like:
Number : IP address
20 1.2.3.4
40 1.2.3.5
80 1.2.3.6
and then the bash script has to bann IPs with more than 30 connections(In our case: 1.2.3.5 and 1.2.3.6) with this:
iptables -A INPUT -s IP_FOR_BLOCK -j DROP
This is following on from:
[url]
So I need to execute a list of commands via a cron job rather than having the script 'wait' for the shell to finish processing (as this was leading to time outs and all sorts of issues).
I'm guessing the way to do this is to have my php set up a cron job to occur at some point in the near future (like current time + 1 min), then to prevent the job from repeating the next hour, it removes itself from the cron list as the final command.
Does this sound like a reasonable way to go about executing a queue of shell commands from the browser that take an indefinite (possibly long) amount of time?
I've been concerned about executing commands through (./) using php and perl shells on the server
a new way of hacking these days is using perl shells , even if the perl was terminated on the server ,, or was forbidden for users
hackers upload a (perl) program to the server to use it instead of the server's own perl
any way ,,
chmoding the (ls-cat-more-less) to 4750 seems to give permission denied when exeuting these programs on the server
but the hackers also found that they could upload their own ls-cat-more-less programs and use them instead of the server's
they also could rename them ls==>ki or anything and use them like this
./ki /etc/valiases -alXrt
and the commands work like charm for them
./ <<--- this command uses the sh program on the server ,, ((sh which refers to bash on most servers))
so
./ki
is the same as
sh ki
and
bash ki
so i tried chmoding sh with 4750 and that killed the exploit
i was concerned about cpanel's and the website's functionality
so i tried changing an accounts password and creating a database ,, they both worked fine
so ,, if u thing chmoding 4750 sh is a bad idea please let me know
and if you know any other ways of disabling all the perl scripts on the server
i got a new sever and was looking at few thing.
just ran netstat and saw this -bash: netstat: command not found
how can i correct it?
I have a problem with my server
when I do
locate ***
-bash: locate: command not found
& I did
updatedb
-bash: updatedb: command not found
if after doing the following and transferring my domains to the server, they will functions properly as far as BIND setup is concerned. This will also serve as installation instructions for others if you can verify that this is all good.
I have installed BIND9 and setup DNS with the following:
------------------------------------------------------------------------
yum install bind-chroot
chmod 755 /var/named/
chmod 775 /var/named/chroot/
chmod 775 /var/named/chroot/var/
chmod 775 /var/named/chroot/var/named/
chmod 775 /var/named/chroot/var/run/
chmod 777 /var/named/chroot/var/run/named/
chown -R named /var/named/chroot/etc
chown -R named /var/named/chroot/var
cd /var/named/chroot/var/named/
ln -s ../../ chroot
cp /usr/share/doc/bind-9.3.3/sample/var/named/named.local /var/named/chroot/var/named/named.local
cp /usr/share/doc/bind-9.3.3/sample/var/named/named.root /var/named/chroot/var/named/named.root
touch /var/named/chroot/etc/named.conf
chkconfig --levels 235 named on
named.conf now contains:
Code:
options {
pid-file "/var/named/chroot/var/run/named/named.pid";
directory "/var/named/chroot/var/named";
query-source address * port 53;
allow-query { any; };
recursion no;
};
zone "server.mydomain.com" { type master; file "server.mydomain.com.db"; };
zone "mydomain.com" { type master; file "mydomain.com.db"; };
zone "mydomain.net" { type master; file "mydomain.net.db"; };
Upload named.conf to /var/named/chroot/etc
Modify /etc/resolv.conf to have the following before its current data:
search mydomain.com
nameserver 127.0.0.1
nameserver 78.129.143.155 // Replace this with the server's IP
// So below these there should be one or more nameserver $ip that point to the ISP's name servers so that the server can download stuff.
Modify /etc/host.conf to become the following:
order hosts,bind
multi on
nospoof on
Modify the files mydomain.com.db and mydomain.net.db and server.mydomain.com.db
to have the correct IP address. (These are DNS zone files that I'm sure are correct so I don't need you to confirm those.)
* Upload them to /var/named/chroot/var/named
/etc/init.d/named start
I'm trying to write some scripts that automate the installation of a website with a content management system. This includes creating domains, installing databases etc via plesk API.
Now we have it creating the domains and databases via plesk, this is not the issue. It's permission problems issuing commands on the server.
I need to have the script install the cms and this requires writing files to a folder on the server owned by a user which is created with the domain.
e.g.
user creates timsdomain.com with ftp user name tim
Plesk makes directory on webserver called ~/vhosts/timsdomain.com/
inside this directory is a folder called httpdocs.
All the files within this folder are owned by tim.
Now my script (running as 'apache' in a folder owned by 'admin') needs to write/edit files to this directory as the user tim (or whatever user was created when the domain was set up).
How can I do this from a php script?
My idea would be to log in as the new user and then start issuing commands but I don't know how to login a user from a script.
I've tried exec, exec_shell etc
trying to log in via script as the new user using sudo/su/suid etc but they all ask for a password (for obvious reasons) but I cannot see a way to send the password to the command with the script. Ssh?
I don't know. Help
Here's some pseudocode that demonstrates what I'm trying to do, if you can think of a better way I'm all ears.
Code:
//User Fills in CMS/Domain information which becomes Form_Data
//uses plesk to create blank domain, create email addresses and empty database
Make_Domain(Form_Data) {
Plesk = Get_Plesk_Object();
Plesk.Create_Domain();
Plesk.Create_Database();
Build_CMS(Form_Data);
}
//HERE IS WHERE I AM HAVING TROUBLE: I can't figure out how to change the user so I can install files to a
// different directory other than the current user's directory (admin)
Build_CMS(Form_Data) {
change_to_user(Form_Data.ftp_username, FormData.ftp_password);
unpack_CMS_archive_into(user_directory); //eg unpack cms.tar into 'timsdomain.com' (if the above command didn't switch the current directory to users home directory)
//initialises CMS config files and installs CMS data to database
Run_Install_Scripts_On_Server(Form_Data);
//albeit complex, most important part of script
Confirm_Tim_Is_Awesome();
}
Confirm_Tim_Is_Awesome() {
while (getTim().has_moustache()) {
echo "<em>You're still awesome. </em>";
}
}
I am trying to see if a file exists on a remote server but am not getting what I expect. (This is my first Bash script).
Code:
remotefile=[url]
localfile=globaldown.sh
if [ -f "$remotefile" ]
then echo "we have the file remote"
else echo nothing to download from remote server "$remotefile"
fi
if [ -f $localfile ]
then echo we have the local file "$localfile"
else echo "no local file"
fi
it is seeing the local file but not the remote file.
I can copy and past the "echo $remotefile" into my browser and the path is correct.
also wget will fetch the remote file so it should see that it exists.
if it is possible to set sequential commands on a cron job?
Meaning, there is more than one shell commands following the first one.
i was wondering if there's a way i can create a number of files in a sequential order via bash.
i have a file, 'example.ext', i want to duplicate this so that i have:
1example.ext
2example.ext
3example.ext
4example.ext
.
.
.
300example.ext
i could use a bash list ('{' and '}') with the cp command but i believe the curly braces can be used as the source parameter and not the destination.
i could write a shell script but i'm not too conversant with shell scripting.