New topic: applescript for executing terminal commands
<http://forums.realsoftware.com/viewtopic.php?t=47560> Page 1 of 1 [ 6 posts ] Previous topic | Next topic Author Message seanclancy Post subject: applescript for executing terminal commandsPosted: Wed Apr 10, 2013 5:04 pm Joined: Fri Jan 08, 2010 9:59 am Posts: 296 I am creating a utility for RS users to create musical notation based on ABC and the ABCm2ps tool. Right now it works perfectly on Windows. I call a shell command to a bat file which then executes a series of console commands and this produces a png ready for use in my software. I'm a long-time window user so this is not a shock to me... However, I'm pretty new to the mac and I was wondering how I would do this bat file in the mac? I've heard the term applescript bandied about and there is also RBscript... What sort of file executes terminal commands on the mac when called? Here's the bat file contents: @echo off rem delete SReader1.mid REM %1 is the running directory for this batch file REM %2 is the abc file to convert CD %1 abc2midi SReadermusic.abc abc2abc SReadermusic.abc -n 2 -usekey +2 REM abcm2ps -v -s 0.6 -B2 -l %2 abcm2ps -v -s 1.0 -B2 %2 java -jar batik-rasterizer.jar out001.svg in the windows folder that this is, there is the Batik library (which is Java which will convert SVG to PNGs) and the windows version of abcm2ps, abcmidi. I've created a folder for the apple version of my software with all the apple ABC programs in it. What would I use in place of the BAT file? Top simulanics Post subject: Re: applescript for executing terminal commandsPosted: Wed Apr 10, 2013 5:21 pm Joined: Sun Aug 12, 2007 10:10 am Posts: 1041 Location: Boiling Springs, SC seanclancy wrote:I am creating a utility for RS users to create musical notation based on ABC and the ABCm2ps tool. Right now it works perfectly on Windows. I call a shell command to a bat file which then executes a series of console commands and this produces a png ready for use in my software. I'm a long-time window user so this is not a shock to me... However, I'm pretty new to the mac and I was wondering how I would do this bat file in the mac? I've heard the term applescript bandied about and there is also RBscript... What sort of file executes terminal commands on the mac when called? Here's the bat file contents: @echo off rem delete SReader1.mid REM %1 is the running directory for this batch file REM %2 is the abc file to convert CD %1 abc2midi SReadermusic.abc abc2abc SReadermusic.abc -n 2 -usekey +2 REM abcm2ps -v -s 0.6 -B2 -l %2 abcm2ps -v -s 1.0 -B2 %2 java -jar batik-rasterizer.jar out001.svg in the windows folder that this is, there is the Batik library (which is Java which will convert SVG to PNGs) and the windows version of abcm2ps, abcmidi. I've created a folder for the apple version of my software with all the apple ABC programs in it. What would I use in place of the BAT file? an SH file you can also Dim myShell as new Shell Shell.execute "abc2midi SReadermusic.abc" Shell.execute "abc2abc SReadermusic.abc -n 2 -usekey +2" Shell.execute "REM abcm2ps -v -s 0.6 -B2 -l %2" Shell.execute "abcm2ps -v -s 1.0 -B2 %2" Shell.execute "java -jar batik-rasterizer.jar out001.svg" without creating any files... especially if the program will be installed using an installer this would be the best method since mac and windows no longer allows files to be written in the program folder/applications directory... pick a location for the creation of files such as Special.ApplicationData (a member of FolderItem) _________________ Matthew A. Combatti Real Studio 2012 r1.2 Visit Real Studio Developer's Spot! Systems I Use: Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/ Windows Server 2011/CentOS 5.4 /ReactOS/SimOS ~All REAL Compatible~ Top seanclancy Post subject: Re: applescript for executing terminal commandsPosted: Wed Apr 10, 2013 5:33 pm Joined: Fri Jan 08, 2010 9:59 am Posts: 296 My folder will be sitting in the library/application support/Guitar/ABC/MACConvert folder so there will be no qualms about writing to it. these abc apps are libraries and are accessed via terminal commands - they aren't installed (which is very cool). You just have them in the folder and they work. Naturally, I will get absolute filepaths to each of the apps and the files I need to retrieve. So,these shell commands you suggested would run like like terminal commands? Top simulanics Post subject: Re: applescript for executing terminal commandsPosted: Wed Apr 10, 2013 6:38 pm Joined: Sun Aug 12, 2007 10:10 am Posts: 1041 Location: Boiling Springs, SC seanclancy wrote:My folder will be sitting in the library/application support/Guitar/ABC/MACConvert folder so there will be no qualms about writing to it. these abc apps are libraries and are accessed via terminal commands - they aren't installed (which is very cool). You just have them in the folder and they work. Naturally, I will get absolute filepaths to each of the apps and the files I need to retrieve. So,these shell commands you suggested would run like like terminal commands? Shell is direct access to the terminal. Don't forget to use myshell.close when all commands are sent. (replacing myshell with whatever you declares as new shell) or you could run into errors. You can also use myshell.result to check each commands terminal output to check for errors. Review the shell documentation. There is active and inactive shell which either keeps the same terminal (shell) running between commands, but you should be ok without knowing this aspect using the example above. As always if you run into an issue, we're here. _________________ Matthew A. Combatti Real Studio 2012 r1.2 Visit Real Studio Developer's Spot! Systems I Use: Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/ Windows Server 2011/CentOS 5.4 /ReactOS/SimOS ~All REAL Compatible~ Top seanclancy Post subject: Re: applescript for executing terminal commandsPosted: Thu Apr 11, 2013 5:44 am Joined: Fri Jan 08, 2010 9:59 am Posts: 296 I tried using the terminal in the folder with abcm2ps and when I ran it I got Permission denied... Will these shell command run it without errors - or regardless of permissions? Top simulanics Post subject: Re: applescript for executing terminal commandsPosted: Thu Apr 11, 2013 9:40 pm Joined: Sun Aug 12, 2007 10:10 am Posts: 1041 Location: Boiling Springs, SC seanclancy wrote:I tried using the terminal in the folder with abcm2ps and when I ran it I got Permission denied... Will these shell command run it without errors - or regardless of permissions? Just for fun, move your abc files outside of library:applications to a user owned path or elevate your permissions using "sudo". See how that works... _________________ Matthew A. Combatti Real Studio 2012 r1.2 Visit Real Studio Developer's Spot! Systems I Use: Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/ Windows Server 2011/CentOS 5.4 /ReactOS/SimOS ~All REAL Compatible~ Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 6 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
