Skip to Content
It is currently October 25th, 2020, 6:32 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: May 25th, 2012, 12:33 am 
Offline
Alumni
Alumni

Joined: March 9th, 2004, 9:54 pm
Posts: 826
Location: Tallmadge, Ohio, USA
Ever want SAM to combine a bunch of WAV files to play or open a ShoutCast server on-the-fly? AutoShell makes that happen.

How does it work? It is a program that sits on your desktop waiting for communication from PAL. PAL sends it a command and then it replies to PAL to tell it if the command was successful or not. Simple enough!

Image
AutoShell Interface With SAM 4.9.6

Configuration is easy, the hardest part is writing the PAL script. ;)

Need proof? Listen to StudioHits (http://www.studiohits.com/listen/) on the :00 and :30 and you'll hear timed announcements, this is all ran by AutoShell!

Cost? HAH! No cost at all. If you want to donate, please Paypal me via this link: https://www.paypal.com/cgi-bin/webscr?c ... THR9ZPMFJJ

Download: http://www.nexmix.com/files/AutoShell_1_0.zip
Version 1.0: Initial Release
  • .NET Program
  • External executables go into the App Directory
  • Allow for special Pass Key so no random injections
  • Hide Command Window on Execute (You'll want to Show while debugging PAL scripts)

Here is a PAL example, it shows you how to connect to AutoShell:

Code:
{
Description
This PAL script is configured to send data to AutoShell.
Made by Chris "Kewl" Haslage
}

PAL.LockExecution;

//===============================================================================
// Settings - Change these as required
//===============================================================================

var URL        : String = 'http://127.0.0.1:9000';
var PASS_KEY   : String = '0000'; // Auto Generated in AutoShell
var START_CHAR : String = '?';    // Default Value is ?
var SEPARATOR  : String = '|';    // Default Value is |
var END_CHAR   : String = '^';    // Default Value is ^

//===============================================================================
// CODE BELOW LINE
//===============================================================================
var postResult : String = WebToStr (URL + START_CHAR + PASS_KEY + SEPARATOR +
                 'command #1' + SEPARATOR +
                 'command #2' + SEPARATOR +
                 'pause' + END_CHAR);

WriteLn('Post Status: ['+postResult+']'); // OK is good / ERR is bad

if (postResult = 'OK') then
   Begin
      {Good Code Goes Here}
   End
Else
   WriteLn('An error with AutoShell has occured.');

     
PAL.UnlockExecution;
PAL.WaitForPlayCount(1);
PAL.Loop := true;
Enjoy and share your creations!

_________________
Chris Haslage, Founder
http://www.studiohits.com/

Proud SAM Broadcaster user and beta tester since 1999!


Last edited by Chris_Kewl on May 28th, 2012, 8:17 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
PostPosted: May 25th, 2012, 12:40 am 
Offline
Alumni
Alumni

Joined: March 9th, 2004, 9:54 pm
Posts: 826
Location: Tallmadge, Ohio, USA
Here is the first AutoShell submission, which also runs on StudioHits.com, the timed station announcements. Currently this runs on StudioHits on the :00 and :30. It will say any time and sound like real speech with no hard PAL tweaks.

Make sure to get the required files found in the PAL below.

Code:
{
Description
This PAL script is configured to send data to AutoShell.
Made by Chris "Kewl" Haslage on 8/14/11

This simple will combine multiple time elements into one file for SAM.

Needed:

MP3Wrap can be found at:
http://mp3wrap.sourceforge.net/

ID3 can be found at:
http://blog.forret.com/2007/08/id3exe-ideal-tool-for-tagging-and-renaming-mp3-files/

Audio Files can be found at:
http://www.nexmix.com/files/time.zip
}

PAL.LockExecution;

//===============================================================================
// Settings - Change these as required
//===============================================================================

var URL        : String = 'http://127.0.0.1:9000';
var PASS_KEY   : String = '0000';        // Auto Generated in AutoShell
var START_CHAR : String = '?';           // Default Value is ?
var SEPARATOR  : String = '|';           // Default Value is |
var END_CHAR   : String = '^';           // Default Value is ^
var DIR        : String = 'c:\StudioHits\time\';    // Where the MP3s are stored.
var MP3_LOC    : String = 'c:\StudioHits\';         // Where the output file goes.
var MP3_NAME   : String = 'timenow.mp3'; // Output file name.
var MP3_WRAP   : String = '_MP3WRAP';    // MP3Wrap Specific Tag
var MP3_TITLE  : String = 'The Best of the Greatest Hits'; // ID3 Changer
var MP3_ARTIST : String = 'StudioHits.com';                // ID3 Changer
var AtTimes : Array of Integer = [28,58];
//===============================================================================
// CODE BELOW LINE
//===============================================================================

//MP3Wrap Specific Renaming for SAM
var thePos      : Integer;

thePos := Pos ('.', MP3_NAME);
var MP3_OUT : String = MP3_NAME;
Delete (MP3_OUT, thePos, Length(MP3_OUT));

var EXT : String = MP3_NAME;
Delete (EXT, 1, thePos -1);

MP3_WRAP := MP3_OUT + MP3_WRAP + EXT;
//WriteLn(MP3_WRAP);
//MP3Wrap Specific Renaming for SAM

var randomInteger : Integer = 0;
randomInteger := RandomInt(4) + 1;

var hh,mm,ss,ms   : Integer;
var ampm          : String = 'AM';
var padmm         : String = '';

DecodeTime(Now,hh,mm,ss,ms);

if (hh = 0) then hh := 12;
if (hh > 12) then
Begin
   hh := hh - 12;
   ampm := 'PM';
end;
if (mm < 10) then
   padmm := '0' + IntToStr(mm)
else
   padmm := IntToStr(mm);

// Example String
// mp3wrap.exe output.mp3 file1.mp3 file2.mp3 file3.mp3|cd c:\|ren output_MP3WRAP.mp3 output.mp3

var output : String = URL + START_CHAR + PASS_KEY + SEPARATOR +
             //Delete old file if still there
             'DEL ' + MP3_LOC + MP3_NAME + SEPARATOR +
             //Combine MP3s
             'mp3wrap.exe "'+ MP3_LOC + MP3_NAME + '" ' +
             '"' + DIR + 'currenttime' + IntToStr(randomInteger) + '.mp3" ' +
             '"' + DIR + IntToStr(hh) + '.mp3" ' +
             '"' + DIR + padmm + '.mp3" ' +
             '"' + DIR + ampm + '.mp3" ' + SEPARATOR +
             //ID3 Editor (Because MP3Wrap puts junk in ID3)
             'ID3.exe -1 -2 -3 -a "' + MP3_ARTIST + '" ' +
             '-t "' + MP3_TITLE + '" ' +
             '"' + MP3_LOC + MP3_WRAP + '"' + SEPARATOR +
             //Change Directory
             'cd ' + MP3_LOC + SEPARATOR +
             //Rename Files
             'REN ' + MP3_WRAP + ' ' + MP3_NAME + END_CHAR;

WriteLn('Output: ' + output);
var postResult : String = WebToStr (output);
WriteLn('Post Status: ['+postResult+']'); // OK is good / ERR is bad

WriteLn('Current Time is ' + IntToStr(hh) + ':' + padmm + ' ' + ampm);

if (postResult = 'OK') then
   Begin
      Queue.AddFile(MP3_LOC + MP3_NAME, ipTop);
      CAT['Jingles (All)'].AddFile(MP3_LOC + MP3_NAME, ipTop);
      CAT['Play once and erase'].AddFile(MP3_LOC + MP3_NAME, ipTop);
   End
Else
   WriteLn('An error with AutoShell has occured.');

PAL.UnlockExecution;

PAL.Loop := true;

_________________
Chris Haslage, Founder
http://www.studiohits.com/

Proud SAM Broadcaster user and beta tester since 1999!


Top
 Profile  
Reply with quote  
PostPosted: January 21st, 2013, 3:21 pm 
Offline
New User
New User

Joined: January 21st, 2013, 3:18 pm
Posts: 1
Is there a simple PAL script for the AutoShell to launch a BAT or run an EXE?


Top
 Profile  
Reply with quote  
PostPosted: September 7th, 2013, 10:24 am 
Offline
Experienced User
Experienced User

Joined: September 12th, 2011, 10:05 pm
Posts: 304
Thanks for the app :D

How might one convert a batch file to a PAL script so that Autoshell will be able to run it? I'm trying to convert one over here.

Am I right in understanding the Autoshell can pretty much do any command line activity? Do I enter the whole batch in on 'command' or do I have to split it out?

Edit I think I have my head around it. Will post result shortly.

_________________
Square Eyes


Top
 Profile  
Reply with quote  
PostPosted: September 7th, 2013, 12:22 pm 
Offline
Experienced User
Experienced User

Joined: September 12th, 2011, 10:05 pm
Posts: 304
I got stuck :(

I fear that this shell can't handle .bat variables. I know I could simply create a .bat and open it with Autoshell, but I really want to use PAL variables too if possible.

The following PAL script...

Code:
{
Description
This PAL script is configured to send data to AutoShell.
Made by Chris "Kewl" Haslage, modified by square_eyes
}

const Source = 'C:\source'; // Folder of mp3s to search
const Destination = 'C:\destination'; // Folder to copy the latest file to
const CommandSwitches = '/V /D /Y'; // XCOPY Command switches see here www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true

PAL.LockExecution;

//===============================================================================
// Settings - Change these as required
//===============================================================================

var URL        : String = 'http://127.0.0.1:9000';
var PASS_KEY   : String = '605324'; // Auto Generated in AutoShell
var START_CHAR : String = '?';    // Default Value is ?
var SEPARATOR  : String = '|';    // Default Value is |
var END_CHAR   : String = '^';    // Default Value is ^

//===============================================================================
// CODE BELOW LINE
//===============================================================================
var postResult : String = WebToStr (URL + START_CHAR + PASS_KEY + SEPARATOR +
                 '' + SEPARATOR +

  'setlocal enableextensions' + SEPARATOR +
  'for /f "delims=" %%f in (' + '''' + 'dir /o:d /a:-d /b "' + Source + '\*.mp3"' + '''' + ') do (set latest_="' + Source + '\"%%~nxf)' + SEPARATOR +
  'xcopy "%latest_%" "' + Destination + ' ' + CommandSwitches + SEPARATOR +
  'pause' + END_CHAR);

WriteLn('Post Status: ['+postResult+']'); // OK is good / ERR is bad

if (postResult = 'OK') then
   Begin
   WriteLn('Do something.');
   End
Else
   WriteLn('An error with AutoShell has occurred.');
     
PAL.UnlockExecution;



Has an output in the Autoshell...

Code:
17:50:52> Starts: 6
17:50:52> Ends: 328
17:50:52> Parsed Result: 605324||setlocal enableextensions|for /f "delims=" %%f in ('dir /o:d /a:-d /b "C:\Source\*.mp3"') do (set latest_=" @echo off & setlocal enableextensions
  set myfolder_= @echo off & setlocal enableextensions
  set myfolder_= @echo off & setlocal enableextensions
  set myfolder_=C:\Source\
  for /f "delims=" %%f in (
    'dir /o:d /a:-d /b "%myfolder_%\*.mp3"') do (
    set latest_=%myfolder_%\%%~nxf)
  if defined latest_ (
    echo rem latest file "%latest_%"
   xcopy "%latest_%" "C:\Source\" /V /D /Y
    ) else (
    echo No designated files found in "%myfolder_%")   
  Pause
  endlocal & goto :EOF @echo off & setlocal enableextensions
17:50:53> Disconnected from client...


Is there any other way to command Autoshell to achieve the same result?

_________________
Square Eyes


Last edited by square_eyes on September 8th, 2013, 4:22 am, edited 3 times in total.

Top
 Profile  
Reply with quote  
PostPosted: September 7th, 2013, 9:24 pm 
Offline
Alumni
Alumni

Joined: March 9th, 2004, 9:54 pm
Posts: 826
Location: Tallmadge, Ohio, USA
Okay, I have a clearer understanding of what you're trying to achieve. The answer, sadly, is that there is no way to do this in AutoShell directly.

However, just dump the code you want into a text file THEN execute it with AutoShell. You would want to do a StrToFile to take all of your BAT code into a file. Then just run it with AutoShell.

Another option is to create the file with AutoShell then interact with it by using some input options within your BAT:
http://www.robvanderwoude.com/userinput.php

That is the best I could come up with. AutoShell is mainly supposed to be an A to B situation. I am pleased with all the creations coming out of it though. :)

Thanks!

_________________
Chris Haslage, Founder
http://www.studiohits.com/

Proud SAM Broadcaster user and beta tester since 1999!


Top
 Profile  
Reply with quote  
PostPosted: September 8th, 2013, 3:10 am 
Offline
Experienced User
Experienced User

Joined: September 12th, 2011, 10:05 pm
Posts: 304
"However, just dump the code you want into a text file THEN execute it with AutoShell. You would want to do a StrToFile to take all of your BAT code into a file. Then just run it with AutoShell."

Ah OK good thinking, and this should still allow me to inject my variables with SAM. I'll try that now.

_________________
Square Eyes


Top
 Profile  
Reply with quote  
PostPosted: September 8th, 2013, 4:49 am 
Offline
Experienced User
Experienced User

Joined: September 12th, 2011, 10:05 pm
Posts: 304
Just a thought... what's the best way to write the .bat to file using stringtofile, while maintaining line breaks needed for the batch file execution?

I have created a variable TStringList, ready to write, but I'm not sure how to pass the following into it. Does TStringList have to be written to line by line?

Edit: I'm sure there is a better way, but I finally got it to work. I had to construct the .bat as a single line as I couldn't figure out how to build the file line by line (line breaks) with Pal.

Thanks for Autoshell Chris_Kewl, I'll be using it for some things I haven't been able to do in SAM.

Code:
{
Description
This PAL script is configured to send data to AutoShell.
Made by Chris "Kewl" Haslage, modified by square_eyes, old.square.eyes [at] gee mail dot com to build and execute an external batch file.

This script creates a windows batch file and runs it.
The batch file searches for the most recently created file in a directory, and copies it to a different folder.

It is meant to be part of a greater script for kicking off pre-recorded shows and came about from a need to select and queue the latest file in the folder.

Because SAM and PAL don't have this feature, the necessary commands to run the batch file are passed from PAL through HTTP to the Autoshell app running in the background.

More info on Autoshell can be found here: http://support.spacialaudio.com/forums/viewtopic.php?f=23&t=36288

Variables from other parts of your PAL script can be passed directly to the batch file or along with command line instructions passed to Autoshell.
}

//===============================================================================
// Settings - Change these as required
//===============================================================================

const Source = 'Z:\Source'; // Folder of mp3s to search
const Destination = 'Z:\Destination'; // Folder to copy the latest file to
const CommandSwitches = '/V /D /Y'; // XCOPY Command switches see here www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true
const LineBreak = ' & '; // Adds a line break that the batch file will understand. So that all code can be keept on a single line. There is no need to change this.
const BatchFile = 'Z:\Source\CopyLatestFile.bat'; // Location and name of the file if it exists, or if not, where it will be created.

PAL.LockExecution;

var BatchContents: TStringList;
var i            : Integer;

var URL          : String = 'http://127.0.0.1:9000';
var PASS_KEY     : String = '123456'; // Auto Generated in AutoShell
var START_CHAR   : String = '?';    // Default Value is ?
var SEPARATOR    : String = '|';    // Default Value is |
var END_CHAR     : String = '^';    // Default Value is ^

//===============================================================================
// CODE BELOW LINE
//===============================================================================

// Get started by preparing a blank .bat file
if not fileexists(BatchFile) then
begin
AppendStringToFile(BatchFile,'') // If the file does not exist this will create it
end;

strtofile(BatchFile,''); // Clears the contents of the .bat file by blanking it

BatchContents := TStringList.Create; // Create a temporary list object to build in the .bat code

// Create batch file string list. Note that the final batch file must be a single line string e.g. (line 1) & (line 2) & (line 3). The below automatically add the '&' line breaks and brackets. Batch variables must be in the form !Var!

BatchContents.Add('(@echo off & setlocal enableextensions enabledelayedexpansion)'+LineBreak);
BatchContents.Add('(set myfolder_=' + Source + ')' + LineBreak);
BatchContents.Add('(for /f "delims=" %%f in (' + '''' + 'dir /o:d /a:-d /b "!myfolder_!\*.mp3"' + '''' +') do (set latest_=!myfolder_!\%%~nxf))' + LineBreak);
BatchContents.Add('(if defined latest_ (echo rem latest file "!latest_!" & xcopy "!latest_!" "' + Destination + '" ' + CommandSwitches + ') else (echo No designated files found in "!myfolder_!"))' + LineBreak);
BatchContents.Add('(Pause)' + LineBreak);
BatchContents.Add('(endlocal & goto :EOF)');

for i := 0 to BatchContents.Count-1 do // Loop through the temp list object (-1 because the first line is 0)
AppendStringToFile(BatchFile,BatchContents[i]); // Write to the .bat file on each parse

WriteLn('.bat file ready');

PAL.WaitForTime('+00:00:02'); // Small wait to make sure the OS has saved the file

//Run newly created .bat from Autoshell. This is Chris_Kewl's part.
var postResult : String = WebToStr (URL + START_CHAR + PASS_KEY + SEPARATOR +
'call "' + BatchFile + '"' + SEPARATOR +
'pause' + END_CHAR);

WriteLn('Post Status: ['+postResult+']'); // OK is good / ERR is bad

if (postResult = 'OK') then
   Begin
   WriteLn('Do some other code things here.'); // You can add conditional code here which runs on successful receipt of code by Autoshell.
   End
Else
   WriteLn('An error with AutoShell has occurred.');
     
PAL.UnlockExecution;

BatchContents.Free; // Free up your temp list to avoid memory leaks

_________________
Square Eyes


Last edited by square_eyes on September 9th, 2013, 5:26 am, edited 6 times in total.

Top
 Profile  
Reply with quote  
PostPosted: September 8th, 2013, 4:25 pm 
Offline
Experienced User
Experienced User

Joined: September 12th, 2011, 10:05 pm
Posts: 304
hdradionetwork the answer to your question lies in the script above. Let me know if you need me to help you. Basically you need to put this line
Code:
'call "' + BatchFile + '"' + SEPARATOR +
into the original script at the top of this thread. Where "BatchFile" is the full path to your batch file.

_________________
Square Eyes


Top
 Profile  
Reply with quote  
PostPosted: September 9th, 2013, 9:45 am 
Offline
Alumni
Alumni

Joined: March 9th, 2004, 9:54 pm
Posts: 826
Location: Tallmadge, Ohio, USA
square_eyes wrote:
Edit: I'm sure there is a better way, but I finally got it to work. I had to construct the .bat as a single line as I couldn't figure out how to build the file line by line (line breaks) with Pal.


Have you tried \n\r ? I know it's silly to ask but that would be the first thing to pop into my head. If I have some time later, I will look at TStringList more and see if I can add lines that way. I am opening a text file with that method, so I am curious if I can write the same way.

square_eyes wrote:
Thanks for Autoshell Chris_Kewl, I'll be using it for some things I haven't been able to do in SAM.


Glad to help! Don't forget, you can also donate if you like it and use it! :)

_________________
Chris Haslage, Founder
http://www.studiohits.com/

Proud SAM Broadcaster user and beta tester since 1999!


Top
 Profile  
Reply with quote  
PostPosted: September 9th, 2013, 9:50 am 
Offline
Experienced User
Experienced User

Joined: September 12th, 2011, 10:05 pm
Posts: 304
\n\r ?

_________________
Square Eyes


Top
 Profile  
Reply with quote  
PostPosted: September 9th, 2013, 9:55 am 
Offline
Alumni
Alumni

Joined: March 9th, 2004, 9:54 pm
Posts: 826
Location: Tallmadge, Ohio, USA
square_eyes wrote:
\n\r ?

http://stackoverflow.com/questions/1543 ... tween-them

EDIT:

Try this for Delphi (PAL):
http://stackoverflow.com/questions/2544 ... -in-delphi

_________________
Chris Haslage, Founder
http://www.studiohits.com/

Proud SAM Broadcaster user and beta tester since 1999!


Top
 Profile  
Reply with quote  
PostPosted: September 9th, 2013, 10:51 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8089
Location: Cologne (Germany)
Code:
WriteStr('some text before the break' +chr(13)+chr(10)+ 'some text after the break');


BTW: It's \r\n or CRLF not the other way around.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: September 9th, 2013, 10:54 am 
Offline
Alumni
Alumni

Joined: March 9th, 2004, 9:54 pm
Posts: 826
Location: Tallmadge, Ohio, USA
Mastacheata wrote:
BTW: It's \r\n or CRLF not the other way around.

Yep, after I saw what I wrote I knew I got it wrong, I just was not arsed enough to fix it. :P

_________________
Chris Haslage, Founder
http://www.studiohits.com/

Proud SAM Broadcaster user and beta tester since 1999!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 30 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group