Im trying to run several different scripts on my Mac for data stored in different paths. So I put all said scripts into a folder. In order for a script to work, I have to be cd'd to a specific folder required for said script. I use the scripts to get different types of output (ex: Image volumes, MRI info, etc..).
I was wondering if there was a way to store all my scripts in one directory and assign a shortcut to it. That way, I can cd to my folder, and only type something like $ScriptsFolder/Script_1 to have it. Ive seen this done in the FSL software package, where typing $FSLDIR/data/standard would give you the items in that folder.
UPDATE:
Im using Script=/Users/ray/Documents/Script which works until I close down my terminal to start a new one. Any way to make the setup permanent?
EDITED
Found this helpful in the end.
http://www.techradar.com/how-to/computing/apple/terminal-101-creating-aliases-for-commands-1305638
I used it to create a shortcut to my scripts which are all placed in a folder for easy referencing.
Related
In Windows command prompt, how do I list out the latest created files in a system drive (e.g. C:)?
I would like to test a software that creates unknown temporary files in various places within the system drive, and like to know when each files is created during runtime, and want to make sure that the uninstallation does indeed remove these files.
My idea is to start the program, and repeatedly search in command prompt. Or is there a simpler way to track?
I'm writing an InnoSetup script to deploy software to a user's machine (default c:/programfiles) but I also want the user to be able to navigate to, say, a portable flash drive as well (like on a second page) and then have the installer load files to the HDD (programfiles) and then have it load files onto their selected flash drive - is this possible? How would I go about executing it?
thanks :)
I am not quite sure what you are trying to do but it sounds possible to me.
As you stated you could do this with a second page where you allow the user to select a drive or a directory where some files are.
You can then iterate over all files and install them into the selected program directory you chose in the setup before.
For more information it would be good if you could provide more information but so far this is the best answer i can give you for the provided information.
Maybe this helps you along when listing up all files in a directory:
Inno Setup: list all file names in an directory
And with this you can copy them:
Inno setup filecopy
And if you want a FolderBrowser use this:
Pascal Scripting: BrowseForFolder
I'm on OS-X (Mavericks, if that matters), and I'm making a bash script that will use resources from a folder called "templates". I'm trying to figure out where I should put it (the templates folder). I'd like to make it so the user doesn't need to modify their path when they install it, so I'd rather not do it the way the terminal mysql command does it (it lives in a folder in /usr/local/mysql/bin). I really want to be able to put them into usr/bin, but I don't know if it's "polite" to put folders in there (I don't see any in there).
Right now I'm leaning towards putting the scripts in usr/bin and having the templates in usr/lib. Is that how this type of thing is normally done, or is there another way? I'd like to follow a convention, assuming there is one. I'd also like it to apply to as many Unix platforms as possible (I'd like to put in a directory where bash scripts live that's consistent across as many Unix platforms as possible). Thanks.
If you follow the Filesystem Hierarchy Standard (FHS), your executable goes in /usr/local/bin, while read-only template files go in /usr/local/share/YOURAPP/. To quote the FHS:
/usr/local/share
The requirements for the contents of this directory are the same as /usr/share. […]
and:
The /usr/share hierarchy is for all read-only architecture independent data files.
(Emphasis added)
If the system admin is meant to customize the template files to take effect system-wide, then they would simply go in /etc/YOURAPP/templates (or something like that).
If the template files are customized on a per-user basis, then the modified copies of the templates (copied from /usr/local/share/YOURAPP/templates) need to be saved in the user's directory, under $HOME/.config/YOURAPP/templates or something like that (thanks to technosaurus for the correction).
You mentioned that you want to install the templates in a directory alongside your executable. That is not the standard approach on UNIX, at least going by the FHS. If you really want to go this route, there is a sort of convention of installing your app to /opt/YOURAPP/, using whatever organization you want inside that folder.
In all cases, it is not good practice to install executables directly to /usr/bin, as that directory is considered to be under the exclusive control of the OS/distribution. If you want to install there, the accepted way to do that is to create a package for the package manager of every supported OS/distribution.
I need to share my data and R source files with a coworker who doesn't have any experience with command line. Moreover, I work in Linux while she's under Windows. But she would like to change some constants and recalculate the scripts. So, it would be cool if she could just double click the R source file and R will be executing in the same directory where the source and data files lie. I thought about setting
Rscript -e "source(\"%1\",chdir=TRUE)"
to the association key in the registry, but the filename (%1) will contain backslashes which R will not handle.
Another way is to setwd() to the source directory in the beginning of my script, but I don't know how to obtain it. AFAIK, argv[0] will be R.exe, not the source.R.
Using GUI is not very convenient, either, because it requires to separately change directory and then to load the script.
Do I have to write a R loader (exe or cmd) for this?
A couple of hints, made as someone who works on Windows by day, and Mac OS by night. I create my projects in a Dropbox folder which is common to both machines. I follow this work practice.
I use RStudio on both my machines. I start up RStudio by right-clicking on the script file locally and this sets the working directory to the file being opened. If I then keep all paths in my script relative, then I can share my projects with myself easily :)
I start my scripts by setting a global variable, in a line that looks silly:
DIR <- getwd()
and then I use relative paths throughout the rest of the scripts. with lines like this:
new.path <- paste(DIR, "rel-path", "to", "new", "file", sep="/")
This avoids my having to tinker with profiles on each machine. It does look obvious, but it gives me one place to change the DIR value in case I want the script to point elsewhere, say, in the morning
DIR <- "~/workspace/newproject"
or, in the evening,
DIR <- "c:/R_workspace/yet/a/different/project"
I also have to be careful that I use the same R version and packages as, in a few cases, that has led to hiccups a few times.
It is a simple flow, but effective and allows seamless working across the two systems
Oops. Explorer starts R in the source directory if it is not on network folder. Initially I tried to start it on network folder. So the only thing to do is to copy the files to the local drive, or to map the network drive to a letter.
I've developed a GUI for some build scripts, and am now in the process of deploying it. As the script will be deployed to a number of different machines at various points, I need to use the standard format of directories that the team use.
The GUI consists of a ".fig" file that contains the visual definition of the UI, and a m-script that defines the functionality. I need to locate these two in "fig/" and "m/" folders respectively, but I can't figure out how to. I first searched for an include statement of some kind in the m-script, as when I Run it on its own, the error message in the command window states that the ".fig" file can't be found, but there doesn't seem to be a reference to the ".fig" file anywhere, I assume that it's inferred as both files have the same name but a different extension.
I fear that Matlab's GUI system requires that both ".m" and ".fig" files are in the same location, but this will be an inelegant solution that I'd rather not go for if I can avoid it.
The next thing I'm going to try is to call a script that copies the fig file from the other directory to the same location as the m-script, when it is executed, then deletes that copy once the script exits, which again seems a clunky solution, but will allow me to adhere to the team's organisation conventions.
Does anyone else know of an undocumented means of specifying the relative location of a GUI ".fig" file?
You can export the GUIDE-generated GUI as a single .m file. Check out this blog post: GUIDE GUIs in All One File.
I'm not sure if this is a new feature, or one of those things that has always been there...