петък, 13 септември 2013 г.

How to send email trough console (smtp)

This one took me a whole lot of nerves to figure it out, and in the end, it turned out I was sleeping the whole time.
The idea was to backup the database of my forum and to send it to an email. There are lots of sites suggesting ways to do it, but here's my final choice (source):

NOW="$(date +"%m%d%Y")"
/usr/bin/mysqldump -hlocalhost -uDBUSER -pDBPass DBName | gzip > /BCKlocation/BCK_NAME$NOW.sql.gz
nail -r "sender@email.com" -s "test" -a /BCKlocation/BCK_NAME$NOW.sql.gz RECIPIENT@email.com
This will attach your backup to the email and send it to the recipient email. I spent the whole night trying this, until I figured that the last option is the recipient email and nothing else. It turned out I was sending myself emails on the email I thought I'm sending them from. Quite stupid, but anyway. Note, it's better not to write your password in a file, so if you have the option to do this trough ssh, it's better to use only -p .

Now comes the funny part - how to set up the smtp. Well, I did it with a .mailrc file in which I put:

set smtp=smtp://name.of.the smtp.server:port
set ssl-verify=ignore
set from=user@domain.com
set smtp-auth=login
set smtp-auth-user=user@domain.com
set smtp-auth-password=password

This options depend on your hosting, so you need to check them there. You can also set them without the .mailrc file, just by typing
mailx -v -s "$EMAIL_SUBJECT -S smtp-use-starttls -S ... $TO_EMAIL_ADDRESS
where ... are all of the options you have in the .mailrc.

But that's all. Doing this, you can happily send yourself emails, reminders, and other goodies, just for the fun of it.
The nice part is that you don't need to use your hosting email to do that, you can use any email server supporting smtp.

If you want to use gmail, here's the smtp setting:

set smtp-use-starttls
set ssl-verify=ignore
set smtp=smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user=name@gmail.com
set smtp-auth-password=pass
set from=name@gmail.com

and the command:

$ mailx -v -s "$EMAIL_SUBJECT" $TO_EMAIL_ADDRESS
Nice, huh!
For the man of nail and all its cool options you can see here.

четвъртък, 8 август 2013 г.

How to trim mp3 file with Linux

The short answer:
$ffmpeg -ss 0:00:00.0 -t 00:02:03.9 -i file.mp3 -acodec copy  new_file.mp3
This command will create a file lasting 2:03:9mins.
The longer version was that I desperately wanted to cut the end of one youtube downloaded mp3 file, but for some reason I couldn't do it with
$sudo mpgsplit -X file.mp3 [00:00:00-00:01:45] -o file_crop.mp3
(It told me "mmm, this file does not start with a pack, offset: -2 " and when I tried the "desperate mode" I got an endless loop - FUN!).
So I wanted to find something simple, instead of using Audacity, which seems too complicated for my simple needs. So this was my simple solution.
Note, ffmpeg gives you the following jolly message:
"This program is not developed anymore and is only provided for compatibility. Use avconv instead (see Changelog for the list of incompatible changes)."
But it still works, so anyway.
As for Audacity, you can do the same quite easily (it turns out) - just look at the bottom, there is Begining of Selection - End of selection. Type whatever you want and then click the first wave-button on the top right part of the screen "Trim audio". Then File->Export->mp3 and voila.
Well, can't compete with the one line solution of ffmpeg, right?

понеделник, 18 февруари 2013 г.

No streaming in Second Life

Not that I'm such a fan, but I do enter Second Life every once in a while. And for a long long time, I didn't have streaming, which meant very boring clubbing experience. Today I finally fixed it. I followed the instructions given here:
1. nano .secondlife-install/secondlife
2. UNCOMMENT the following entries (i.e. remove the # in the beginning) so that you have :
export LL_BAD_OPENAL_DRIVER=x

## - Avoids using the FMOD ESD audio driver.
export LL_BAD_FMOD_ESD=x
## - Avoids using the FMOD OSS audio driver.
 export LL_BAD_FMOD_OSS=x
And save (Ctrl+O)
Then, after restarting the client, I had music! Yay!