Author Topic: Script Needed  (Read 2233 times)

Offline yepadoos

  • Contributor
  • ***
  • Posts: 4
Script Needed
« on: November 12, 2010, 04:43:49 pm »
I would like a script that I can execute after unrar that will send an email containing the name of the file that was unrar'd.  I would like to use bmail for the email if possible.  Does anyone have anything like this?

Thanks

Offline Hecks

  • Contributor
  • ***
  • Posts: 2011
  • naughty cop
Re: Script Needed
« Reply #1 on: November 12, 2010, 07:10:07 pm »
The commandline options for bmail as listed here look pretty straightforward:

http://www.petri.co.il/send_mail_from_script.htm

Do you have Powershell or plain cmd.exe for Windows? With Powershell it's easiest to use inbuilt .NET functions with an smtp server, e.g.:

Code: [Select]
$from = "your@email.com"
$to = "some@other.com"
$subject = "Altbinz roxors"
$msg = "Whatever message you want"
$smtpServer = "localhost" # or whatever smtp server address
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($from, $to, $subject, $msg)

Offline yepadoos

  • Contributor
  • ***
  • Posts: 4
Re: Script Needed
« Reply #2 on: November 13, 2010, 06:10:13 pm »
I've gotten pretty close with this:
Code: [Select]
set body="%1 complete. Unrar Directory: %2"

c:
cd c:\program files\tversity\media server
mshare.exe -R

c:\bmail -s smtp.comcast.net -t 847XXXXXXX@vtext.com -f altbinz@protovision.net -h -b %1

I just cannot get it to concat the collection & unrar location into 1 string then email it.

This will send the collection name as an email/text message to my phone.  If I could just concat the  collection and unrar location together it would be perfect but my limited dos capabilities haven't been able to figure it out.

« Last Edit: November 13, 2010, 06:32:01 pm by yepadoos »

Offline Hecks

  • Contributor
  • ***
  • Posts: 2011
  • naughty cop
Re: Script Needed
« Reply #3 on: November 13, 2010, 06:52:46 pm »
Well, once you set the 'body' variable, you need to reference it with %body%, so:

c:\bmail -s smtp.comcast.net -t 847XXXXXXX@vtext.com -f altbinz@protovision.net -h -b %body%

or

... -b "%body%"

whichever works.
« Last Edit: November 13, 2010, 06:54:17 pm by Hecks »

Offline yepadoos

  • Contributor
  • ***
  • Posts: 4
Re: Script Needed
« Reply #4 on: November 13, 2010, 07:52:38 pm »
This finally does what I want, it refreshes the tversity library and sends an email containing the collection and unrar location.  The quotes around the variables was the major issue I was having.  Thanks for your help.

Code: [Select]
set _string=%1
set _string2=%2

:: Remove quotes
   SET _string=###%_string%###
   SET _string=%_string:"###=%
   SET _string=%_string:###"=%
   SET _string=%_string:###=%

:: Remove quotes
   SET _string2=###%_string2%###
   SET _string2=%_string2:"###=%
   SET _string2=%_string2:###"=%
   SET _string2=%_string2:###=%

set body="%_string% complete. Unrar Directory: %_string2%"

echo.%body%

c:
cd c:\program files\tversity\media server
mshare.exe -R

c:\bmail -s smtp.comcast.net -t 8477103017@vtext.com -f altbinz@protovision.net -h -b %body%