NOOB - Scripting to make an App work


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers NOOB - Scripting to make an App work
# 1  
Old 01-19-2011
NOOB - Scripting to make an App work

Hello everyone.

i work in a school and i ran into an application today that is a real pickle. i know how to make it work, but i would need to script it. The way to make it work would be to have a script check each local user profile on login, see if the directory already exists, do nothing if it does, and copy it from a pre-determined location if it doesn't.

for what it's worth, i'm sorry for asking such a basic question, but my district doesn't have the resources to pay a contractor to script this, and i don't know scripting :-(

thanks for reading!

--js
# 2  
Old 01-19-2011
On login, it seems a bit late to check the home dir! If you have a user id and want to clone the home dir, that should be done when the login is created, unless you have a remote global id/password scheme like nispasswd/yppasswd. Here is a simple script, jut off the cuff, to clone a template subtreee I call ~template for one user id and that id's base group:
Code:
#!/usr/bin/ksh
 
if [ $# != 2 ]
then
 echo "
Usage: ${0##*/} user_id group
" >&2
 exit 1
fi
 
zd=$( eval echo '~'"$1" )
 
if [ ! -d "$zd" ]
then
 cp -r ~template "$zd"
 chown -R "$1" "$zd"
 chgrp -R "$2" "$zd"
fi


Last edited by DGPickett; 01-19-2011 at 04:24 PM..
# 3  
Old 01-20-2011
Clarification

Thanks, DGPickett for your response. It would appear that I didn't properly explain what was wrong, though. i'll explain specifically what's wrong below:

*application for music (school play is coming up - guys and dolls) installs and runs with no problem for the user that installed it.
*local administrator (me) installs it in midi lab, and when any OTHER user tries to launch app, it fails.
*after speaking to their tech support, it turns out that it fails because, on install, the installer creates a directory called RMS in Application Support in the user's LOCAL profile, instead of in a universally accessible place. the support people tell me that to make it work, the RMS directory needs to be in EACH user's local home (~/Library/Application Support/RMS).
*my conclusion, after testing several different solutions, is that the ideal way to solve this problem (aside from scrapping the software entirely) is to copy the master RMS folder to each user's local profile on login, if it isn't there already.

Does that make more sense?
# 4  
Old 01-20-2011
Find the one RMS folder and run sudo chmod 777 on it to make it available to everyone, then create aliases or symbolic links in each users home directory to point to the original folder (that they will now have rights to).. That could work as a simple solution..

you could use
Code:
 ln -s /path to RMS folder/RMS ~/Library/Application\ Support/RMS

to link or create an alias to the original folder.
# 5  
Old 01-20-2011
Good idea, but I tried that yesterday, and it didn't work. it doesn't want a link. when it sees the link, it errors. having the actual directory there was the only thing that worked.
# 6  
Old 01-20-2011
OK, then try this (you will need to specify the full path to the folder you wish to copy after the RMS_LOCATION= (between the quotes):
Code:
#!/bin/bash
RMS_LOCATION="/path/toRMS/"
DIR="~/Library/Application Support/RMS"
if [ -d $DIR ]; then
echo ""
else
cp -R $RMS_LOCATION $DIR
fi
exit 0

---------- Post updated at 01:59 PM ---------- Previous update was at 01:53 PM ----------

By the way, the script would need to be run as the user who wishes to have the specified folder added to their respective home directory/Library/Application\ Support/, because the ~ symbol means the home directory path of the current user.. You could simply run my script as the logged in user who needs access to the folder.. you would have to run sudo chmod +x thescriptIgaveyou.sh to make it executable.. Mind you if you are trying to make this a loginhook ( I assume your using Mac because of the Application Support folder) you may have problems because loginhooks run with root privileges.. I suggest to make it executable and just have the user run it if they encounter a problem with RMS and need the folder copied.. You also need to make sure they have the proper permissions for the folder so you could always chmod 777 the folder to make sure it is accessible.
# 7  
Old 01-20-2011
Maybe it needs the top directory, but you can sym-link any content! Or, bettter, you need to install it as a sym-link higher, so it is already traversed.

You could mount it, too, I guess! Might need NFS or the like.

I don't like to leave 777 folders around, as carefree people leave their dodo in my folders and I have a hard time removing it, not usually being root.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Total Noob BASH scripting question

Hello All, I have a file of ip addresses called activeips.txt What I'm trying to do is run a simple bash script that has a loop in it. The loop is a cat of the IP addresses in the file. The goal is to run 2 nmap commands to give me outputs where each address in the list has an OS... (11 Replies)
Discussion started by: Dirk_Pitt
11 Replies

2. Shell Programming and Scripting

Noob to scripting needs some assistance

Hello, I am in a Unix class and have been out of town. I have been tasked to generate a couple of scripts and ahve never done it before. I have a virtual machine running Ubuntu. The task is below Prompt the system administrator for all valid input parameters Generate a menu to ask which... (1 Reply)
Discussion started by: jkeeton81
1 Replies

3. Shell Programming and Scripting

Noob Expect Scripting Question

I'm having some difficulty with convincing Expect to do what I need.. I have a loop that waits for input, a specific phrase of text followed by a single word. I need Expect to capture that word following the specific phrase. It should then store the word in a variable. I'm fairly sure it's... (6 Replies)
Discussion started by: LongLeafTea
6 Replies

4. Shell Programming and Scripting

Noob to Shell Scripting

Hello. I'm attempting to create a shell script to assist me by saving time with one of my hobbies. I am an Android Enthusiast and currently build a few roms for one of the devices. One of the roms I make is ported from a different device to mine (I get the original for the HTC Desire HD and... (3 Replies)
Discussion started by: JHutson456
3 Replies

5. UNIX for Dummies Questions & Answers

Noob scripting question with android ADB commands

Hi I'm pretty new to scripting and I've been googling around looking for an answer but have yet to come up with a proper solution. I work with multiple android devices at a time and I'm looking to simplify my life with a script. Basically I'm looking for a script that takes the device ID's and then... (2 Replies)
Discussion started by: Onyoursix
2 Replies

6. Shell Programming and Scripting

how to make this work

hi, I have been trying to make my script work but could not, tried some of the suggestions from here but I am not getting the correct result. I have a script that was Param1 ="$1" Param2 ="$2" $Script1 log -t "$param1" "$param2" | grep operation > /dev/null || { echo "Message"... (1 Reply)
Discussion started by: rider29
1 Replies

7. Shell Programming and Scripting

Why does my script not work? (Noob Alert)

I am a scripting noob and I have tried to search on google, but cannot find the answer as to why this script doesn't work properly. The idea of this script is that it will list all files starting with f in a certain folder, and delete all but the three newest one. I am trying to achieve this by... (4 Replies)
Discussion started by: bronkeydain
4 Replies

8. Programming

HOWTO: Calculate the balance of work in multi-threaded app.

I was wondering if anyone could give me a good idea how to calculate how balanced the threading is on a multi-threaded application. I want a percentage, such as "threads are 80% balanced." This is the way I am currently going about it, maybe it is good, maybe not. First, whenever a thread... (2 Replies)
Discussion started by: DreamWarrior
2 Replies

9. Shell Programming and Scripting

How to make this work

Dear All, I want acces my folder that name Log , that throught /export/home/hmi/bin/log. I want direct to Log folder. When I try using alias, i'm login as root: >alias logfile='cd /export/home/hmi/bin/Log' and when I execute > logfile this is work, but after I logout and login again as... (3 Replies)
Discussion started by: heru_90
3 Replies

10. Programming

Using make utility to create an mini-app

The following is my makefile. When I run "make", it gives me a bunch of error. I've compiled each file separately and there are no compilation errors. The target is "monprc". Have a look below: monprc: monprc.o monrep.o dsz.o cc -o monprc monprc.o monrep.o dsz.o monprc.o: monprc.c... (1 Reply)
Discussion started by: Yifan_Guo
1 Replies
Login or Register to Ask a Question