Test sendmail
If you want to test send mail you must use the following command: /usr/sbin/sendmail -bv -oL10 test@adriangrigoras.com After that you must check your root’s mail with mail program or mutt.
If you want to test send mail you must use the following command: /usr/sbin/sendmail -bv -oL10 test@adriangrigoras.com After that you must check your root’s mail with mail program or mutt.
If you want to read emails that are send to root, one way is to read with the mail program. An easier way to do this is with mutt.
When you want to copy a file which is generated every day and has a date inserted inside its name, you can use the following bash file: #!/bin/bash dt=`date +%Y%m%d` #dt=`date +%Y%m%d%H%M%S` from_dir=”/home/adrian/1″ to_dir=”/home/adrian/2″ from_file=”$from_dir/myfile”_”$dt”.csv to_file=”$to_dir/myfinalfile.csv”; #echo “cp $from_file $to_file” cp $from_file $to_file #!/bin/bash dt=`date +%Y%m%d` #dt=`date +%Y%m%d%H%M%S` from_dir=”/home/adrian/1″ to_dir=”/home/adrian/2″ from_file=”$from_dir/myfile”_”$dt”.csv to_file=”$to_dir/myfinalfile.csv”; #echo “cp $from_file… Read More »
If you want to remove white spaces with Perl, you can use the following Reggular Expressions Trim all whitespaces: $value=~s/s*//g; # remove all the whitespace Or you can use function to trim the whitespaces from beggining, ending or both: # Perl trim function to remove whitespace from the start and end of the string sub… Read More »
If you want to use a huge csv file, an easy way to do this is to parse it and write another file. Bellow is an example, which takes the values from old_file.csv, do some changes and write another file new_file.csv #! /usr/bin/perl ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); $year=1900+$yearOffset;… Read More »
If you want to view what users are logged in into your system, you can use this command: who Thanks,
For ungziping you must run the following command. This command will replace the .gz file with a .tar file gzip -drv phpbb-platinum-0.5beta.tar.gz After that, you must run the following command: tar -xvf phpbb-platinum-0.5beta.tar That’s it.
If you need to configure more network aliases, you can use the following commands: vi /etc/network/interfaces Add the following lines: auto eth0:0iface eth0:0 inet staticname Ethernet alias LAN cardaddress 192.168.1.101netmask 255.255.255.0broadcast 192.168.1.255network 192.168.1.0 Restart the network service: /etc/init.d/networking restart Now your machine will response also to 192.168.0.101. You can use up to 254 aliases for… Read More »
When you want to run a command and save the output to a file an easy way to do this is by nohup ./myscript.sh & Cheers,
When you need to redirect a visitors to different pages depening on a value from a cookie you can use this code: RewriteCond %{HTTP_HOST} ^mydomain.com$ RewriteCond %{HTTP_COOKIE} !MyDomainCookie RewriteRule ^/$ /first-page.htm [R=301,L] RewriteCond %{HTTP_HOST} ^mydomain.com$ RewriteCond %{HTTP_COOKIE} MyDomainCookie=Value1 RewriteRule ^/$ /second-page.htm [R=301,L] RewriteCond %{HTTP_HOST} ^mydomain.com$ RewriteCond %{HTTP_COOKIE} MyDomainCookie=Value2 RewriteRule ^/$… Read More »