PDA

View Full Version : Help make a simple script




carterx
Jul 11, 2012, 08:18 AM
Don't know a hell of a lot about scripts but right now running into crunch time. In short I need a script that does the following:


mounts a network share (share will be open to "everyone" so will not require username/password)
sudo run command to run a app that sits in that share
delay script for 5 seconds for app to run
unmount the share
delete this script


I need the application to run the first time the computer is imaged then once the small application runs it never needs to run again which is why I want the script to be removed.

Thank you!!

.



jared_kipe
Jul 11, 2012, 10:07 AM
Don't know a hell of a lot about scripts but right now running into crunch time. In short I need a script that does the following:


mounts a network share (share will be open to "everyone" so will not require username/password)
sudo run command to run a app that sits in that share
delay script for 5 seconds for app to run
unmount the share
delete this script


I need the application to run the first time the computer is imaged then once the small application runs it never needs to run again which is why I want the script to be removed.

Thank you!!

.

Wow. Such an honor to work for you. I'll get right on it. Out of curiosity, what language do you, I mean I, want to use to accomplish all this? Especially the sudo part, that should be cake and doesn't sound suspicious at all.

carterx
Jul 11, 2012, 10:40 AM
Wow. Such an honor to work for you. I'll get right on it. Out of curiosity, what language do you, I mean I, want to use to accomplish all this? Especially the sudo part, that should be cake and doesn't sound suspicious at all.

haha well this is not for bad use :cool:

But that said I think I have a better work around though still need some script help.

I have six Mac labs that I need to deploy an image to but we have software that needs to be activated as it will break if the serialized before being imaged. The work around is to serialize the application after the computer is imaged. I've built an exactable that I can run on the Mac as soon as it is imaged which will serialize the application then close.

I will place this app within the image but would like to build a .sh script that will be used with DeployStudio that will run during post ghost. I want the script to run the app, delay for 5 seconds then delete the executable so users will no have access to this to copy for themselves.

jared_kipe
Jul 11, 2012, 12:03 PM
haha well this is not for bad use :cool:

But that said I think I have a better work around though still need some script help.

I have six Mac labs that I need to deploy an image to but we have software that needs to be activated as it will break if the serialized before being imaged. The work around is to serialize the application after the computer is imaged. I've built an exactable that I can run on the Mac as soon as it is imaged which will serialize the application then close.

I will place this app within the image but would like to build a .sh script that will be used with DeployStudio that will run during post ghost. I want the script to run the app, delay for 5 seconds then delete the executable so users will no have access to this to copy for themselves.

If you already have an executable that does it, why 'delay for 5 seconds' instead of just waiting for the executable to exit/return?

carterx
Jul 11, 2012, 12:21 PM
When Deploy Studio after the computer has been imaged it runs a post ghost session then reboots. It's during this post ghost session that I want this to run so other Technicians do not need to go around and run this manually. This way the script runs to tell the application to open which takes about 3-4seconds to patch the computer with the SN# and close on it's own. I then want the script to delete the executable so it's no longer on the computer. I don't want students to grab it and use it for their own personal use.

If I don't do this then when other Tech's image their labs they have to go around to each desktop and manually login, run the executable then delete it.

kryten2
Jul 11, 2012, 12:28 PM
You might want to take a look at the following commands :

mount
open
sleep if you need it
umount
rm

Look into the man pages of every command on how to use them eg man mount etc.

jared_kipe
Jul 11, 2012, 01:54 PM
When Deploy Studio after the computer has been imaged it runs a post ghost session then reboots. It's during this post ghost session that I want this to run so other Technicians do not need to go around and run this manually. This way the script runs to tell the application to open which takes about 3-4seconds to patch the computer with the SN# and close on it's own. I then want the script to delete the executable so it's no longer on the computer. I don't want students to grab it and use it for their own personal use.

If I don't do this then when other Tech's image their labs they have to go around to each desktop and manually login, run the executable then delete it.

Yeah... redescrbiing it isn't what I'm asking for. My point is that typically, for a shell script, when you write a script that say, installs, something every line waits for the previous line to complete.

yum update
yum install {whatever}

Would be pretty funny if you had to guess how long it would take and do something like:

yum update
sleep 25
yum install {whatever}
sleep 5
rm myself


EDIT: Also, presuming the script runs with sufficient privileges to accomplish what you are wanting, why bother removing the app? Why not just put it in a location the typical user wouldn't have access to?