Posts Tagged ‘perl’

The following is a quick and dirt list of Linux command to do some useful operation.

# To check disk space usage on some/dir

du -h --max-depth=1 /some/dir

# To check all open ports on a Linux system

netstat -puntal

# To create a random password

ps aux | md5sum | cut -c1-8

# To process a text file as argument for a command

while read line
do
echo "${line}";
done < textfile.txt

# To login to cyrus to administer mailboxes

cyradm --user=cyrus --auth=login localhost

# To reconstruct a Cyrus Imap Mailboxes

su - cyrus
/usr/lib/cyrus/bin/reconstruct -rfx "user.mailbox"

# To manage CPAN modules
# To start the installation of the needed perl modules from CPAN type the following on your shell:

perl -MCPAN -e shell

# If you haven’t configured the Perl CPAN installation before, you’ll have to go through the initially setup and evt. install the following:

cpan> install CPAN
cpan> install LWP

# After that we can start installing the needed packages:

cpan> install Archive::Tar
cpan> install Archive::Zip

# To manage mail redirections with SIEVE script

if header :contains "Subject" "****SPAM****" {
fileinto "INBOX/SPAM";
}
if header :contains "X-Spam-Flag" "YES" {
fileinto "INBOX/SPAM";
}

Hope this help

Bye
Riccardo

Print This Post Print This Post

This has been written to detail how to generate a CPU load in a Virtual Machine..

Some tipical scenarios where you may wish to generate CPU load within a virtual machine include stress testing an ESX server and triggering DRS VirtualMachines migrations for demonstration or testing purposes.

The simple scripts below can be used to generate CPU load in Windows and Unix\Linux virtual machines and will run continuously until terminated.

  • Windows Virtual Machines
    The VBscript script below should be saved as cpubusy.vbs.
    Start it by double clicking it and terminate it by ending the wscript.exe process in Task Manager.

Dim goal
Dim before
Dim x
Dim y
Dim i
goal = 2181818
Do While True
before = Timer
For i = 0 to goal
x = 0.000001
y = sin(x)
y = y + 0.00001
Next
y = y + 0.01
Loop

  • Unix\Linux Virtual Machines
    The Perl script below should be saved as cpubusy.pl
    Start it by opening a terminal window, changing to the directory where it is saved and typing the following:

chmod 744 cpubusy.pl
./cpubusy.pl

Terminate it pressing CTRL-C.

#!/usr/bin/perl

$goal = 2181818;
while (TRUE) {
for ($i=0; $i<=$goal; $i++) {
$x = 0.000001;
$y = sin($x);
$y = $y + 0.00001;
}
next;
$y = $y + 0.01;
}

Hope this help

Bye
Riccardo

Contacts
Look at me at Linkedin Follow me on Twitter
My Flickr Albums My Facebook profile My YouTube Videos
SkypeMe My Linux Counter GMail me
Search
Google Search
Categories
Tag Cloud 3D
FeedBurner RSS

Visitors
Locations of visitors to this page
VMware related Blogs
The following are Blog sites with feeds I personally follow. When I'll have some spare time I will complete all Feed and Twitter links.