Running Daily Scripts

Is there a way i can run scripts for logs on time basis using the database.
I have log table where every transaction is stored , i need just one values from all those transactions everyday by the end of the day or at a specified time stored in a separate table.
My main tables are runtime so an update would result in change in data and i want to save this data on daily basis.
Is there an automated way of doing it?
Note: I do not want to use no triggers.
Ashish

dbms_job lets you schedule jobs in the database that will run at a given time. There are a couple of threads in the "Database - General" forum today on that package.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • Not Been Able To Run Daily/Weekly/,Monthly Scripts

    I was running Onyx as usual and was surprised that it would freeze whenever running the "scripts" option. I then downloaded a trial version of Cocktail after uninstalling Onyx and my macbook got stuck again at the weekly scripts. Then I installed a new version of Onyx and again the application stopped responding! I tried via Terminal too but there was no indication that something is happening. I am using the latest version of Tiger.
    I dont understand why something like this is happening. Should I be worried? Also I think my macbook has become a little slower and even Mail takes forever to open!

    Hello,
    Sometimes the weekly scripts take more than 10 minutes to run, with absolutely no feedback whatsoever. (I think weekly takes the longest time of the 3 types.) Did you get the grey screen of death, or just assume it was freezing since nothing was happening? If you force quit a weekly job, it takes slightly longer the next time you run it. My advice is to run weekly, go get lunch, and come back and see if it is done.

  • Running Maintenance Scripts for Mac OS 10.5.8 HELP!

    I am trying to run the maintenance scripts on my laptop for the first time. I go to Terminal type in "sudo periodic daily weekly monthly" and hit return. A warning message pops up the some data may be lost.... and the the Password prompt comes up. I back up consistently so I just want to run the scripts since it has never been done. However, when I try to type in my password, NOTHING types. I hit return and tried again, but nothing. Can someone please help me figure out what is wrong and if there is any other maintenance I need to do to the system?
    Thanks in advance for any help.

    You don't need to use any utility, or perform any procedure, to make sure OS X's built-in maintenance tasks have run under OS X 10.5 and later.
    OS X 10.5 will run its cron jobs automatically (actually, they are no longer handled by the UNIX facility "cron", they are now handled by a similar facility called "launchd". if that means anything to you) whether you have left your computer on all night or not. You no longer need a utility to run missed maintenance as of OS X 10.5. It will run automatically at the next available opportunity. Actually, this was the case as of OS X 10.4, but a bug kept the maintenance routines from running more than once per restart under OS X 10.4. This was fixed in OS X 10.5
    http://discussions.apple.com/message.jspa?messageID=6552347
    http://arstechnica.com/reviews/os/macosx-10.4.ars/5
    http://developer.apple.com/macosx/launchd.html

  • Cron.daily scripts ran multiple times since cron package update

    Since cron package update I get a weird behaviour with cron.daily scripts. Indeed these scripts are executed multiple times, which is somewhat annoying for big backup.
    I added this little script in cron.daily to show this :
    #!/bin/bash
    # Test cron
    date >> /var/log/date_cron
    And I get this :
    Mon Feb 22 11:27:53 CET 2010
    Tue Feb 23 11:27:13 CET 2010
    Tue Feb 23 11:37:16 CET 2010
    Tue Feb 23 11:44:45 CET 2010
    Wed Feb 24 12:05:08 CET 2010
    Wed Feb 24 12:15:59 CET 2010
    Wed Feb 24 12:22:59 CET 2010
    Thu Feb 25 12:24:32 CET 2010
    Thu Feb 25 12:31:49 CET 2010
    Thu Feb 25 12:35:01 CET 2010
    Thu Feb 25 12:45:30 CET 2010
    Fri Feb 26 12:44:37 CET 2010
    Fri Feb 26 12:52:56 CET 2010
    Fri Feb 26 13:02:18 CET 2010
    Sat Feb 27 13:04:10 CET 2010
    Sat Feb 27 13:13:50 CET 2010
    Sat Feb 27 13:22:06 CET 2010
    Sat Feb 27 13:28:49 CET 2010
    Sun Feb 28 13:29:49 CET 2010
    Sun Feb 28 13:35:19 CET 2010
    Sun Feb 28 13:44:18 CET 2010
    Sun Feb 28 13:49:52 CET 2010
    Mon Mar 1 13:38:06 CET 2010
    Mon Mar 1 13:47:02 CET 2010
    Mon Mar 1 13:55:55 CET 2010
    Tue Mar 2 13:58:21 CET 2010
    Tue Mar 2 14:01:56 CET 2010
    Tue Mar 2 14:08:14 CET 2010
    Wed Mar 3 14:06:35 CET 2010
    Wed Mar 3 14:15:44 CET 2010
    Wed Mar 3 14:24:24 CET 2010
    Thu Mar 4 14:25:04 CET 2010
    Thu Mar 4 14:33:16 CET 2010
    Thu Mar 4 14:41:33 CET 2010
    Fri Mar 5 14:43:35 CET 2010
    Fri Mar 5 14:47:05 CET 2010
    Fri Mar 5 14:53:14 CET 2010
    Sat Mar 6 14:53:32 CET 2010
    Sat Mar 6 14:58:50 CET 2010
    Sat Mar 6 15:04:18 CET 2010
    Sun Mar 7 14:58:30 CET 2010
    Sun Mar 7 14:58:30 CET 2010
    Sun Mar 7 15:09:07 CET 2010
    Sun Mar 7 15:13:29 CET 2010
    Mon Mar 8 15:12:19 CET 2010
    Mon Mar 8 15:12:19 CET 2010
    Mon Mar 8 15:20:50 CET 2010
    Tue Mar 9 15:24:35 CET 2010
    Tue Mar 9 15:24:35 CET 2010
    Tue Mar 9 15:31:58 CET 2010
    We can see that the script is executed three times a day instead of one.
    Here is /var/spool/cron/root :
    # root crontab
    # DO NOT EDIT THIS FILE MANUALLY! USE crontab -e INSTEAD
    # man 1 crontab for acceptable formats:
    # <minute> <hour> <day> <month> <dow> <tags and command>
    # <@freq> <tags and command>
    # SYSTEM DAILY/WEEKLY/... FOLDERS
    @hourly ID=sys-hourly /usr/sbin/run-cron /etc/cron.hourly
    @daily ID=sys-daily /usr/sbin/run-cron /etc/cron.daily
    @weekly ID=sys-weekly /usr/sbin/run-cron /etc/cron.weekly
    @monthly ID=sys-monthly /usr/sbin/run-cron /etc/cron.monthly
    How can I restore the wanted behaviour ?

    Svenstaro wrote:This bug still appears. Is dcron still being worked on?
    $ crontab -l
    # DO NOT EDIT THIS FILE MANUALLY!! USE crontab -e INSTEAD.
    # <minute> <hour> <day> <month> <dow> <command>
    0 0 1 1 * /usr/bin/update_dcron
    uh-oh

  • Do i need to run maintenance scripts

    does OS 10.6 still run
    daily  weekly and monthly maintenance scripts

    Hi m,
    The scripts are still performed in the early morning hours, but most people don't have their Macs awake at that time on a regular basis. Running them is very quick in Terminal.
    sudo periodic daily weekly monthly

  • Run Maintenance Scripts

    On my PM G5 in the past I have successfully run maintenance scripts as follows:
    periodic daily weekly monthly
    from the terminal window with no problems. Usually when the command line is
    executed the sys asks for master password and when it is entered, the program runs
    without further messages, only cursor displayed, until it finishes and returns
    the command line prompt.
    Now suddenly when the command is executed the sys returns:
    208-106-62-250:~ richardrkelley$ periodic daily
    /usr/sbin/periodic: line 1: /var/log/daily.out: Permission denied
    /usr/sbin/periodic: line 106: 370 Broken pipe date
    cat: /tmp/periodic.7sKejqD8Mz: Bad file descriptor
    cat: /tmp/periodic.7sKejqD8Mz: Bad file descriptor
    cat: /tmp/periodic.7sKejqD8Mz: Bad file descriptor
    208-106-62-250:~ richardrkelley$
    I have run the disk utility and repaired permissions and repaired the disk
    with no change. There were some minor repairs done to permissions and disk.
    I would appreciate advice as the how to fix this problem and to prevent
    future occurrence of same.
    Thanks all.

    Oops; I had a senior moment.
    The correct command to run maint scripts is:
    sudo periodic ........
    sorry for the dumb question.

  • Running Maintenance Scripts

    Anyone have a suggestion as to what program might be best for Leopard? 'Maintenance' (with the wrench icon) and Cocktail, and Onyx won't work on 10.5 ????!!!
    Any other programs available?
    Thanks

    ChicagoLarry,
    I was curious about the same thing, so I've typed the following in my Terminal window to see what has run and when:
    ls -la /private/var/log/*.out.
    What I've found is a bit odd...
    With Macaroni turned off, the scripts seem to run on my iMac after it has been awakened from sleep--that's good. However, they don't seem to run on my Powerbook after it's been awakened...I don't understand why...
    Also, I had a problem with the latest version of Macaroni initially running the weekly script on my iMac... It tried to run the script but couldn't seem to complete it. After I manually ran the scripts (sudo periodic daily weekly monthly), then Macaroni seemed to accomplish them ok. (I've had Macaroni turned off on both my computers until I can verify that (1) it's needed, and (2) it properly runs daily, weekly, and monthly scripts...)
    So, to answer your question: The definitive answer is either, "I don't know," or "It depends."
    More research to do!!
    Woo Hoo!
    Bob

  • Running "nightly scripts" and other behind the scenes tasks

    I keep seeing posts about how the iMac Intel runs nightly scripts and/or other tasks behind the scenes. There is no mention of this in the user manual nor does Apple warn you about not putting the computer to sleep so that these tools will run. My iMac hard drive is asleep every night (as am I...) how can I get these things to run manually? How often? And can someone point me to literature to support this info?
    Thanks much,
    HS

    522/2968
    Hi HS,
    "There is no mention of this in the user manual"
    That's because the three nightly maintenance scripts are not important at all, and don't affect Mac OS X performance.
    They are only a relic from the glorious Unix system times when it was used on rather small capacities HDs, on computers that were running non stop for months or years...
    Running them yourself manually, as a "perfectionist measure", can be done easily using the "daily, weekly & monthly" features in OnyX or Cocktail for example. All three tasks together, once a month or so, is fine. No harm (but useless) rerunning them many times.
    Litterature:
    The KB article is quite old, it shows only the default 10.2 times and commands:
    - http://docs.info.apple.com/article.html?artnum=107388
    (almost same as 10.3 and 10.4 though)
    What I really would like to learn, is whether the scripts have been modified in the Intel version of Tiger.
    Could you please (or Joseph or somebody else), in Finder, Go To (shiftcommandG) this folder:
    /private/etc/
    see if there is still the same
    /private/etc/periodic
    folder, with the three
    /private/etc/periodic/daily
    /private/etc/periodic/weekly
    and
    /private/etc/periodic/monthly
    scripts?
    (I'm asking because I don't own an Intel Mac myself).
    Next you would Go To (⇧⌘G) this folder:
    /System/Library/LaunchDaemons
    please, see if you find those three files
    /System/Library/LaunchDaemons/com.apple.periodic-daily.plist
    /System/Library/LaunchDaemons/com.apple.periodic-weekly.plist
    and
    /System/Library/LaunchDaemons/com.apple.periodic-monthly.plist
    If they are still there, you can open them (with TextEdit if your Developer Tools are not installed), and read the default times when the tasks are scheduled to run.
    Thanks in advance!
    Axl

  • How to run daily checkup with applescript

    hello, i heard that macs run a script late at night for something between 2 and 5 in the morning. but my computer is asleep so those scripts don't run. so i run them manually through terminal. i was curious to know if there is a way in applescript or automator to run them daily so i don't have to?
    thx

    Kappy's Personal Suggestions for OS X Maintenance
    For disk repairs use Disk Utility. For situations DU cannot handle the best third-party utilities are: Disk Warrior; DW only fixes problems with the disk directory, but most disk problems are caused by directory corruption; Disk Warrior 4.0 is now Intel Mac compatible. TechTool Pro provides additional repair options including file repair and recovery, system diagnostics, and disk defragmentation. TechTool Pro 4.5.2 is Intel Mac compatible; Drive Genius is similar to TechTool Pro in terms of the various repair services provided. The current version, 1.5.1, is Intel Mac compatible.
    OS X performs certain maintenance functions that are scheduled to occur on a daily, weekly, or monthly period. The maintenance scripts run in the early AM only if the computer is turned on 24/7 (no sleep.) If this isn't the case, then an excellent solution is to download and install a shareware utility such as Macaroni, JAW PseudoAnacron, or Anacron that will automate the maintenance activity regardless of whether the computer is turned off or asleep.
    OS X automatically defrags files less than 20 MBs in size, so unless you have a disk full of very large files there's little need for defragmenting the hard drive. As for virus protection there are few if any such animals affecting OS X. You can protect the computer easily using the freeware Open Source virus protection software ClamXAV. Personally I would avoid most commercial anti-virus software because of their potential for causing problems.
    I would also recommend downloading the shareware utility TinkerTool System that you can use for periodic maintenance such as removing old logfiles and archives, clearing caches, etc.
    For emergency repairs install the freeware utility Applejack. If you cannot start up in OS X, you may be able to start in single-user mode from which you can run Applejack to do a whole set of repair and maintenance routines from the commandline.
    When you install any new system software or updates be sure to repair the hard drive and permissions beforehand. I also recommend booting into safe mode before doing system software updates.
    Get an external Firewire drive at least equal in size to the internal hard drive and make (and maintain) a bootable clone/backup. You can make a bootable clone using the Restore option of Disk Utility. You can also make and maintain clones with good backup software. My personal recommendations are (order is not significant):
    1. Retrospect Desktop (Commercial - not yet universal binary)
    2. Synchronize! Pro X (Commercial)
    3. Synk (Backup, Standard, or Pro)
    4. Deja Vu (Shareware)
    5. PsynchX 2.1.1 and RsyncX 2.1 (Freeware)
    6. Carbon Copy Cloner (Freeware - 3.0 is a Universal Binary)
    7. SuperDuper! (Commercial)
    The following utilities can also be used for backup, but cannot create bootable clones:
    1. Backup (requires a .Mac account with Apple both to get the software and to use it.)
    2. Toast
    3. Impression
    4. arRSync
    Apple's Backup is a full backup tool capable of also backing up across multiple media such as CD/DVD. However, it cannot create bootable backups. It is primarily an "archiving" utility as are the other two.
    Impression and Toast are disk image based backups, only. Particularly useful if you need to backup to CD/DVD across multiple media.
    Visit The XLab FAQs and read the FAQs on maintenance, optimization, virus protection, and backup and restore.
    Additional suggestions will be found in Mac Maintenance Quick Assist.
    Referenced software can be found at www.versiontracker.com and www.macupdate.com.

  • Why am I being asked if I want to run a script?

    I have a script application set to run daily via Ical. For some reason, now when the script begins running at the assigned time a window comes up asking me to "Press run to run this script". I don't recall this coming up previously, and (I'm new to scripting) I'm not sure how to script this away. I just want the script to go ahead and run, without a go ahead from me. Any thoughts?
    Thanks.

    When you save a script as an application, there are some check boxes near the bottom of the file dialog, one of which turns off that cover.

  • How can I run a script last?

    Hiya,
    I have a single backup job running a single dataset. That single dataset has an include statement to include a dataset directory, which holds individual datasets for the several hosts I want to back up, each with potentially different parameters. This works well, the hosts back up in some order (I don't care), everything's happy.
    However, what I want to do is add a step on the end of this process to run a report on the admin server after all the backups are complete. That is, to run a script once, last.
    If I add an "after backup" command in the dataset, it runs it (as stated in the manual) on the client servers, after every backup, which is no good to me. I've tried creating a separate job and scheduling it at a lower priority a few minutes later than the backup job, but that seems to just run when it feels like it, I presume because there aren't any conflicts so why shouldn't it?
    Can anyone advise how I should be doing this?
    Related question... I've tried putting an "after backup" step on the Catalog backup job, but that appears to get run twice (I presume because there are two "include" steps in the catalog dataset)! Is this expected? How can I get it to just run once, after the catalog backup is complete?
    Thanks,
    David.

    Thanks Donna, but... no. It didn't work.
    We've actually purchased a license for OSB, so I've fired this question at our official support channel now, and they came back with the same answer at the same time (are you the Oracle techie looking at my problem, by any chance?). For the record here's (with some tweaks for readability in this context) what I've sent back in response to that article.
    From the article, I thought perhaps the following might do the trick:
    include dataset /Hosts {
    after backup optional "/usr/local/osb/pre-n-post after-fsd-hosts mail"
    But, from the log:
    2010/11/05.07:26:58 trouble parsing dataset in FSdaily line 1 - open brace appears where not allowed (OB dataset mgr)
    "010/11/05.07:26:58 offending line is "include dataset /Hosts {
    2010/11/05.07:26:58 trouble parsing dataset in FSdaily line 3 - bad nesting (OB dataset mgr)
    "010/11/05.07:26:58 offending line is "}
    So it appears I’m not actually allowed to do that. I don’t understand why that would be.
    The only other idea I have is to include a dummy backup step, backing up something really small (because OSB won’t let you run a backup without backing anything up - sigh!), tack a script onto that, and hope like heck OSB decides that it should run that last. All the documentation I’ve read gives the impression that datasets are all about scope, not order, so I’m not altogether confident that this will work. In any case, it seems a pretty kludgy way of doing it! And, given the next paragraph below, I’m not all that sure it’ll work in any case.
    My idea of scheduling a catalog backup for five minutes later than the client backups, with a lower priority, so that it runs when the client backups finish, also has a flaw - if I use two tape drives in parallel, it runs the catalog job in parallel with the last client job, which is completely useless. I want to put on the end of the tape a backup of the catalog as at just after the client backups, so that in the case of a disaster I can restore that and I’ll be good to restore everything else.
    In addition to being completely useless for the purposes of putting an “after” catalog backup on the end of the tape, it’s also completely useless for the purposes of running a script last - I tried the following:
    include catalog {
    after backup optional "/usr/local/osb/pre-n-post after-catalog mail"
    This ran the pre-n-post script twice, once for each component of the catalog, which is altogether not what I want it to do.
    I can’t think of any way to achieve a catalog backup on the end of the script except for scheduling it for some time later and hoping the dataset backups always finish by then. Ugly.
    The only way I can think to achieve the run-a-script-last is to munge all the datasets together into one humongous dataset file, and do stuff as in the article to try to bend OSB to my will (again, hoping that OSB obeys the order of statements in the dataset). Which, when I’m given the ability to use “include dataset /Hosts” to make it easy to maintain, seems a bit of a mean trick to pull on me. And, again, with two tape drives available I’m not at all sure it’ll work in any case.
    I'll post further results as they come to light...
    David.

  • I run a script in win 7 Enterprise it worked but not in window 8.1

    I run a script that hides folders and it worked in window 7 Enterprise, but then when I tried it in window 8.1 it did not work at all. Is there something I am missing ?
    public void StartDir()
    DirectoryInfo dii;
    String discT = @"C:\\Test0137";
    String disc1 = discT + @"\NotePsn";
    dii = Directory.CreateDirectory(disc1);
    ToggleHidden(disc1);
    public void ToggleHidden(string filename)
    string path = filename;
    DirectoryInfo di = Directory.CreateDirectory(path);
    di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;

    Following the suggestion from Thomas, I modified my script. It worked perfectly on my Window 7 Enterprise.Then I just took my flash-memory(where my script reside) and plugged it in my laptop (window 8.1) and started to run the script but it did not hide
    the directory I intended to hide, and I did not get any  error message either. I also tried to generate directories in different discs ...still it did not work. This Script is the corrected version after the suggestion of Thomas and Michael Taylor:
    public void StartDir()
    DirectoryInfo dii;
    String discT = @"C:\\Test0137";
    String disc1 = discT + @"\NotePsn";
    dii = Directory.CreateDirectory(disc1);
    ToggleHidden(disc1);
    public void ToggleHidden(string filename)
    string path = filename;
    DirectoryInfo di = new DirectoryInfo (path);
    di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;

  • How to run a script on Oracle server from isqlplus

    Hi I am trying to run a script on my workstation from Oracle server through isqlplus workarea. I entered following command and get the following error. i have enabled isqlplus URL by editing web.xml file already. Can please someone help how to run the script?
    @http://myaixserver.com:5560/scripts/Databasestartupstages.sql;
    SP2-0920: HTTP error 'page not found (505)' on attempt to open URL

    So far, you haven't specified your rdbms version and isqlplus behaved differently on a 9iR1, 9iR2 from the one release on 10gR1/R2. on 9i it was a servlet based on a JServ servlet executor machine, meanwhile on 10g it is a J2EE compliant application deployed on an OC4J container, so configuration is different.
    You may want to take a look at these references -->
    * Starting iSQL*Plus from a URL
    * Creating Reports using iSQL*Plus
    ~ Madrid

  • Running Permission Scripts for App-V packages in VDI environment

    Hi
    We use App-V 5.0 SP1 in VDI environment.
    We have a major problem with packages' permissions
    Our users don't have administrative privileges on their machines.
    As the option for "Security Descriptors" is discontinued, the only way to give permissions to a folder in a package is to use the VFSCACLS.vbs as a startup script of a package.
    This way the first time users launch an application they're prompt to reopen it, and the second time they can use the application with the needed permissions.
    The problem:
    The script saves those permission changes under LOCALAPPDATA\AppV...
    Therefore, everytime the users logoff the folder is deleted (VDI...) and again, they must run the script for the first  again to get the permissions back after logon!
    We cannot roam the LOCALAPPDATA\AppV folder as its size can be dozens of GBs...
    Folder permissions with group policy is also not a solution, as the folder name changes everytime we upgrade a package and it's impossible to follow with hundreds of packages.
    So it's either we're missing something critical in the architecture with VDI environment or there's a normal solution for these situations.
    Would love to get some help
    Thanks
    Tamir Levy

    Hi Nicke
    that's what I did! the problem is that I find my self over and over again want to sequence packages in App-V 5.0 and forced to sequence it in App-V 4.6.
    I really hope that it wasn't App-V team's goal. announcing App-V 5.0 and tell us it doesn't support many things so we will still need App-V 4.6 forever.
    I have to maintain 2 different App-V environments with 4 different servers , 4 different sequencers and 2 clients on each computer. it doesn't make any sense for me to forced to stay with both of the versions forever.
    correct me if I'm wrong but App-V 4.6 is a legacy application. the new versions cover only support on newer operating systems and nothing more. I won't be surprised if in the next version of MDOP won't come with App-V 4.6 anymore and Microsoft will announced
    it's unsupported very soon.
    Every time I open a ticket with MS Support the best thing I get is "It's a known issue, we can't tell when it will be fixed"
    can you help me more ? move it forward to other people from the inside? at least agree with me that something is not as expected in App-V 5.0... :(
    I love the technology, I believe in it, I'm kinda depend on it and I only want it to be better
    Tamir Levy

  • Applescript: How to run a script once upon logon for multiple users

    I'm deploying a NetRestore image to about 150 Macs which will be using Active Directory and I've designed a custom default user for each new user. However, our system requires a specialized certificate that has to be installed on the local login.keychain for each user otherwise network connectivity is impacted.
    I've tried to use the security command through Terminal to install the certificate, but no matter what combination of commands, I cannot seem to get that to work properly even with an already-created user. While it will often say it's installed, the cert will not actually show up in the login keychain in Keychain Access. And the network connectivity is still impacted.
    So instead, I created a brief AppleScript that just gives the user brief instructions to click "Add" on the prompt for which Keychain to add the cert and then "Always Trust" for the "This cert is not verified" prompt. Then it launches Keychain Access. Originally, I was going to have it actually click the buttons for the user, but I realized trying to get the whole Accessibility apps and assitive devices to work on every new user would be a nightmare.
    I created the script on another 10.9 Mac using Automator to make it an actual application. I've used the instructions in OS X: Using AppleScript with Accessibility and Security features in Mavericks to sign it and I'm using root to move it from its network location into the Applications folder. I've adjusted the permissions to allow all Admin users to r/w (along with everyone else). To the root user, it shows as a usable application, but every other user on the Mac sees it as damaged/incomplete.
    What I want to do is add it to the default Login Items, so I can run the final AppleScript command to simply remove the login items listing. That way I don't need to worry about it running again, but it's still available for the next user to sign onto the deployed Mac.
    I know it's a little convoluted, but this is the final piece to the NetRestore deployment I've been working on for months. Any suggestions on how to make this work (or even a completely different solution) would be greatly appreciated.
    Here was the original shell script in case you're curious.
    #!/bin/bash
    ## Prompt for current user admin for use in Certificate Install
    while :; do # Loop until valid input is entered or Cancel is pressed.
        localpass=$(osascript -e 'Tell application "System Events" to display dialog "Enter your password for Lync Setup:" default answer "" with hidden answer' -e 'text returned of result' 2>/dev/null)
        if (( $? )); then exit 1; fi  # Abort, if user pressed Cancel.
        localpass=$(echo -n "$localpass" | sed 's/^ *//' | sed 's/ *$//')  # Trim leading and trailing whitespace.
        if [[ -z "$localpass" ]]; then
            # The user left the password field blank.
            osascript -e 'Tell application "System Events" to display alert "You must enter the local user password; please try again." as warning' >/dev/null
            # Continue loop to prompt again.
        else
            # Valid input: exit loop and continue.
            break
        fi
    done
    echo $localpass | sudo security import /'StartupFiles'/bn-virtual.crt ~/Library/Keychain/login.keychain
    osascript -e 'tell Application "System Events" to delete every login item whose name is "LyncCert"
    And this is the AppleScript itself. (I used the \ to make it easier to read. The first line is actually one complete command)
    display dialog "Click OK to start installing Mac Network Certificate." & return & return & \
    "In the following prompts, click the 'Add' then 'Always Trust'." & return & return & \
    After you have clicked 'Always Trust', quit Keychain Access." default button 1 with title \
    "Mac Network Certificate Install"
    activate application "Keychain Access"
    tell application "Finder" to open POSIX file "/StartupFiles/bn-virtualcar.crt"
    tell application "System Events" to delete login item "Lync-AppleScript"
    end
    Thank you for your help!

    I have run into this same issue. Are you trying to run the script one time as a new  user logs in or everytime a user logs in?

Maybe you are looking for