AppleScript SCPT corrupted file - applescript

I have an Applescript file that got corrupted and does not seem to be working anymore. I have tried almost everything and several script softwares, and none seemed to help.
What I would like to do, is recover (at least a part of) the script that could be read by Applescript Editor from my current scpt file. I have tried with osadecompile utility from Mac OS, but I get an error -1752 (errOSABadStorageType), and by looking at the scpt file, it seems to have stopped in the middle of it's execution (when it was supposed to grab file sizes and write them down in a Text file using TextEdit).
If possible, I would like to know if there is a tool that could read the beginning of this SCPT file and provide at least some partial code from what the original script was. It seems all other solutions require the full structure of a SCPT file to provide the final syntax.

Related

Get file type in Ruby for files without extension

I'm trying to programmatically read the file type for PostScript font files on a Mac using Ruby. The files do not have extensions, and it is possible that some are corrupt or incomplete (due to inconsistencies in how the fonts were packaged many years ago). If I inspect the file in Finder, it clearly displays the information I need:
However, I am not sure how to extract this information in Ruby. Here is what I've tried:
Reading/parsing the file using the File class results in empty content
otfinfo returns an error: "OTF file corrupted (too small)"
I also tried using FileMagic, even though it is no longer maintained, but the output is not helpful, i.e.:
FileMagic.new.buffer(font_file) => "ASCII text, with no line terminators"
FileMagic.new(FileMagic::MAGIC_MIME).file(font_file) => "inode/x-empty; charset=binary"
All of this is expected behavior, because of the aforementioned issues with these files (as well as various issues with PostScript fonts in general), but I wanted to share it to be thorough in what I've already attempted.
All I want to know is how I can get that exact piece of information that is showing up in the Finder, to show up in my Ruby script. Is there some other class that can access the same thing that the Mac is using to populate the "Kind" field?

Octave- How to automatically execute commands on startup

I'm new to octave, and want to run a few commands on startup automatically every time it opens.
I typed "help startup" and saw "Octave uses the file ".octaverc". I did a bit of searching online at https://www.math.utah.edu/docs/info/octave_4.html, and saw the .octaverc file should be in the following path:
OCTAVE_HOME/lib/octave/VERSION/startup/octaverc
PROBLEM:
In that directory I don't have a startup folder, only "oct" and "site". I do see hidden files, which was my first thought since the file begins with "." character. So I then used Agent Ransack in the directory, and still nothing came up.
QUESTION:
1) Do I have to make the startup folder and octaverc file myself?
2) If so, does one, both or none have to be hidden?
3) Can it be a txt file, or does it have a special extension?
4) Do I just type the commands straight into the file or is there special formatting?
NOTE:
In case I'm going about this the wrong way, there are the operations I'd like to have run on startup:
PS1('>> '), addpath('D:\Users\Me\Desktop'), clc
Thanks ahead of time for the help!!
Possible locations (and their differences) for octaverc files are specified in the documentation.
In short, these are, from more general to specific:
octave-home/share/octave/site/m/startup/octaverc (most generic, for entire system)
octave-home/share/octave/version/m/startup/octaverc (to cover for more than one octave versions installed on the system, possibly requiring different startup scripts)
~/.octaverc (where ~ is unix-speak for a user's home directory -- covering for user-specific startup files)
.octaverc files in any directory, creating specific startup conditions for specific directories
octaverc files are effectively simple script files that are executed from most generic to most specific each time octave starts. Therefore, in the presence of conflicting commands, the more specific file can effectively be used to override the more generic behaviour.
Octave also supports (but does not recommend) the use of the startup.m file, for matlab compatibility.
You might also want to check out pathdef and savepath as well.
As a more general tip, if you ever want to search for a specific keyword from the documentation (e.g. octaverc), you can type this kind of search query in duckduckgo (or google):
octaverc site:https://octave.org/doc/interpreter/
(or just download the documentation as pdf and search the pdf)
Found the solution, the file was in the following path:
OCTAVE_HOME/share/octave/site/m/startup
to find out where OCTAVE_HOME is for you, just type "OCTAVE_HOME" into your Octave command line window.
ANSWERS:
1) You do not have to make a startup octaverc file yourself
2) The file is actually not hidden, so it should be easy to find given you're looking in the right place.
3) The file doesn't have an extension. It's just octaverc.
4) Under the last line of the existing file, you can just append commands as you would type them at the Octave command line window.
the last(7.3.0) octave version placed HERE:/ does not find the THERE:/openEMS/matlab directory even it is already loaded with octaverc or addpath. It keeps looking into the work dir where openEMS is not placed and does not recognize, for instance, the 'physical_constants.m' file.

Conventional command line tool OSX save data location

Im making a command line tool for Mac that does some work on .strings files. Part of the process is making a backup of the .strings files it will operate on so that, in case something gets messed up, the user's files will still be safe somewhere for retrieval.
What directory is in your opinion best to save such data? I'm assuming a temp directory of sorts but not sure where that should be. If this was an application in the macOS sense, i could store this data in the application folder. However this is a command line tool which will be added in /usr/local/bin, following the UNIX way of doing things, and it would feel "wrong" to put that data in there.

Editing Info.plist of Xcode project using AppleScript?

How can I edit info.plist file of xcode project? I have tried searching a lot but nothing specific.
An info.plist file can be considered 2 ways. One, it's just a specially formatted text file so thinking that way you can manipulate the text directly. Applescript can read text files, manipulate text, and write text files. Two, it's a basic xml file formatted with apple's tags to create a "plist" file. So you could use xml tools on the file as well. System Events has xml tools. There's also a unix command line program called "defaults" that can work on them as well.
So there's several tools. You need to think about what you want to do, how complicated the task is, and then decide which tool will best fit your requirements.
After you figure out those basics, try some things and come back and ask specific questions.

Compiling applescript from a text-only source file

Is there a way to compile apple script code on the command line from a text source file, like you know, the way it is done in every real programming language? I have an applescript .app file and it seems the only way to edit it is using the native script editor app. However not having a source text file results in all kinds of problems when the binary is loaded into different environments. From what I can tell, it is not even possible to edit the source in the binary in many cases if the script editor is for whatever reason unable to load the binary file.
What I am trying to do is make it so that I can compile it in the environment it will run in. Any suggestions are appreciated...
Try the osacompile command.

Resources