How to make a script auto install under Ubuntu - installation

I have pretty big assignment where I had to create some files for word frequency checks and a bash script connected with a crontab to make these function run under a specific set of folder every 5 minutes.
The last step here is to somehow compress these folders and scripts so anyone can easily install it on another computer, so some sort of auto installer for these scripts.
I'm not really sure what I should use, if a tarball can achieve this or if I need to use some sort of packet manager to be able to complete this step.
I would be really thankful if someone can explain the best way to complete this, and preferably some links to some documentation about this.
Thank you.
--
Just to clarify,
I need this to some how create the directories and subdirectories like it's looking now, and preferably have something that adds the function automaticly to the crontab record.

The proper way to do that is a .deb package. You would install the cron in /etc/cron.d/
You could also use a shar and add the commands you need to that. Or use tar, let the user extract it in a temp directory then tell them to run an installer. In that installer (which you would write) use either ordinary cp commands, or the install command.

Related

Trying to Set a Shortcut to a Directory

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.

Samba multiple file permission masks

I'm running windows 7 and using samba with vagrant/virtualbox/ubuntu (all latest). Most of the files in my share are standard code with permission 0664, so in the config I've set create mask = 0664 and that's working great. However I've got a sprinkling of bash files with permission 0755. Most of the time they are in directories with other files that are 0664, so I can't just reconfigure entire directories in my config (nor do I want to keep track of all the directories). Is there some way I can apply a permission to files of a specific extension? Or even better have samba somehow maintain file permissions when saving?
As an aside, I'm using sublime (v3065) on windows to edit the files on my share, so perhaps if it's not doable in the smb config I could modify sublime's properties to do it?
As far as I know there is no way to set samba create masks specifically per file extension. I don't know if Sublime has a way, but I doubt it. There is also no way to set Umask to do this.
In this case, what I would do is create a simple bash script to find .sh / .bash files, and chmod them. Then cron schedule that script to run every (n) minutes. The cpu bandwidth of such a script will be negligible.
If you are not sure how to write the script, or schedule it, let me know and I will show you.
There could be a better answer out there, but at least for now this will solve the problem.
:-)

Updating Batch files via Dropbox

So, there isn't anything big that I'm really going to use this for, but I've have made a little batch (.bat) program that I thought would be awesome if I had this feature in it.
I don't want anything that is going to mess up my LAN network, so try to make it as simple
as possible.
So my idea is that I want it so when the program starts it scans for an update (which will be found on Dropbox), then ask the user if they want to update, then it will install an update file and delete the old one. If anyone knows a way to do this safely, please tell me, thanks!
I have a tiny bit of an idea on how this is possible, but it is not very efficient. Thanks!
I assume you have a file on your computer and one on Dropbox and sometimes you want to edit it from another computer and then when you get back home and start up the program it will check whether the Dropbox file is more up to date than the one you have on your computer?
I think the easiest way would be to either use a special file name, like, myBatchFile_update.bat or something and then make your program check for that file in your Dropbox folder. If it's there, copy it and then rename it to myBatchFile.bat or something. Also rename update file. You may want to look up copy and xcopy and ren, first.
Another way would be to keep the "if updated" information inside of the file in a function (although it's hardly functions in batch). Or you could just keep another file called for example is_updated.bat where you keep information about whether it's updated or not. You echo something like set update=true (if it's updated) to the update file when it has updated and when you have edited the program you also edit the update file so that it says false. Then, when you need the information, you just call the update file.

File watcher in shell

I am trying to keep two directories synchronized with the same files in them.
Files are dropped into Directory A throughout the day. I would like to create a file watcher script that will copy files from Directory A to Directory B as soon as they are dropped.
My thought was to run the job every minute and simply copy everything that dropped in the last minute, but I am wondering if there is a better solution out there.
I'm running MKS toolkit under Windows. Different servers, same operating system.
Thanks for your help!
If you use Linux, you can hook into the kernel using the inotify API to get notified if something in a folder changes. There are command line versions like inotifywatch(1) as well.
To copy the files, I suggest to use rsync(1): it is clever, knows how to clean up after itself and it will create new files hidden while they are copied so users and programs are less likely to pick them up before they are complete.

How can I set an AppleScript to run when a given file is modified?

I know that applescripts can be set to run as folder actions, but is there a way to get them to run as file actions? Yes, I know I can work around this by just making a new folder, putting the script in it, and running as a folder action, but I want to know if this can be done.
I cross-posted this question to Apple's Applescript discussion board, and a few users there gave some solutions that use only system resources, with no third-party applications. Follow the link to see the answers.
Basically you need to use launchd to watch a file and launch a script when the file changes. Then you'd need to craft a .plist that describes the script to run and the file(s) or directories to watch.
There's no simple built in way to do this. However there's lots of ways to set up an Applescript to run. However in general you'll have to do some non-Applescript coding.
Check out the info in this hint and OSXHints:
http://hints.macworld.com/article.php?story=20060817044149264
They have a Python script demonstrating using fsevents.so to monitor file changes. You would then just modify the Python to call your Applescript (or simply use Appscript to do the scripting from within Python).
Alternatively you can just have a program check a file at a particular interval and then run if the file changes. This hint describes that in Perl:
http://hints.macworld.com/article.php?story=20031001073403810
I found a way to do this that works.
Shell script:
find watchedfilepath -mtime -1 -exec cp {} watchedfolderpath ';'
Create a Calendar Event in Automator to run this shell script which will check the file. If it has been modified in the last 24 hours, then it will be copied to the watched folder. Then create an action in Automator to move it to trash (otherwise the next time the shell script runs it won't work).
Set up a Folder Action on the watched folder to watch for an added new item and then it will let you know. I have created a script to send me an email and put that in the Folder Actions folder in Library/Scripts. It works like a treat.
This is an old question, but the Apple Automator tool in MacOS does exactly this. You can set it to watch a folder and execute an Applescript, Shell Script, etc.

Resources