Change directory and execute script

I'm trying to write a small program that gets 4 input values from the user and based on the first 3 values will change to a specific directory on a unix system. Using the fourth value it will execute a perl script in the directory. The fourth value is a variable in the script command line. What are some of the ways to get the program to do a CD and execute the script? Thanks for any suggestions/help. Steve

I'm trying to write a small program that gets 4 input
values from the useryou can use prompt for console app or build a gui
and based on the first 3 values
will change to a specific directory on a unix system.skip that step
Using the fourth value it will execute a perl script
in the directory. Runtime.exec() is what you need or something to that effect (Google)
The fourth value is a variable in
the script command line. What are some of the ways
to get the program to do a CD and execute the
script? Thanks for any suggestions/help. Stevejust execute the script using the full path, not sure CD will do anything for you

Similar Messages

  • Cd not changing directory in shell script

    This shell script executes correctly, but... not correctly:
    #!/bin/bash
    cd /var/www/vhosts/mydomain.com/httpdocs
    pwd
    Output is:
    /var/www/vhosts/mydomain.com/httpdocs
    [root bin]#
    However, when I immediately type "pwd", it returns
    /usr/bin
    How can pwd in the script return a path different from the path I am in?

    [Running a script launches a subshell|http://tldp.org/LDP/abs/html/subshells.html], and the subshell does change the default, and that default promptly evaporates when the subshell exits.
    You can invoke the script as dot-space-scriptname or as +source script+ to avoid the subshell.
    . ~/script
    source ~/script
    Or you can switch tactics and use a bash function:
    function cdhttpdocs() {
    cd /var/www/vhosts/mydomain.com/httpdocs
    The easiest for this case is probably something akin to an alias:
    alias cdhttpdocs="cd /var/www/vhosts/mydomain.com/httpdocs"

  • VERY simple find and execute script to be improved

    hello, I've been searching for other scripts like the following but have found nothing, so decided to hack this together. I have almost 0 bash programming experience, so I'm sure some kind soul could easily improve it. The functionality should be obvious to anyone here. It could probably do with some limit to the files being searched for, but I only use it in directories and with queries that I know won't give lots of results. Obviously, if there's some better script/option that my google fu couldn't find, then please let me know. Smart arse one liners more than welcome.
    #!/bin/bash
    finder=`find ./ -iname "*$1*" -printf %p\:`
    IFS=:
    select filename in $finder
    do
    echo "enter command to run on $filename"
    read commandtodo
    $commandtodo $filename
    break
    done
    unset IFS

    Just after I went to bed lastnight I figured out the simplest way (i.e. only way I understand) to do what I wanted - just put it as a function in your .bashrc file.  Export doesn't work from a script back to the shell it was called from - that's what I was trying to say last night. So then, the final function is this:
    fns() {
    export IFS=:
    select X in `find ./ -iname "*$1*" -printf %p\: `
    do
    echo "enter command to run on $X"
    read commandtodo
    $commandtodo $X
    break
    done
    unset IFS
    This works great. If any newbies stumble upon this page (I've been looking for something like this since I started using the command line) then I'll briefly run through how it works:
    1 - you type "fns x" where x is a word or partial word you know is in the filename
    2 - you select whichever of the found files/directories you want
    3a - you can then enter a command to run (e.g. vim)
    3b - or just hit ctrl-c to return to the prompt, and then use $X in place of wherever you would have put the path in the command you want to run. e.g. "cd $X" will move you to that directory, if it was a directory you were looking for
    Hope this helps someone
    As for the other options from Procyon/karol - thanks, but again, over my head. I don't think I have xdotool installed. Script didn't work anyway, but mine is fine for now.
    Thanks

  • Dbms_Scheduler and executable script

    Hi,
    I have a scenario. I was running a shell script (which in turn runs an oracle procedure) every 30 minutes and put it in cron. Now, this was before when the procedure used to take less than 30 minutes.
    Now a days, intermittently, it takes MORE than 30 minutes. So, the second run of the procedure is not obeying the limits set for the program.
    What I would like to have is have ONE instance of the shell script(it emails after the procedure is run), running at any given time. So, if the cron fires up and it sees that there is already one instance of the script running and this shouldn't run now.
    The way I was trying to do this is like this:
    i). Use dbms_scheduler to run the executable and somehow (I need help here on how) stopping the next run to not fire IF there is one already running.
    or
    ii). Use dbms_scheduler to run the actual procedure and somehow allowing only ONE run of the procedure at any given time (In this scenario, I have to take care of the email from Oracle itself instead of from unix).
    or
    iii). There is another solution where I was using autonomous transaction to update a table that the program is running and then NOT run the same procedure when it is already running. But, since this is an in-house solution and Oracle might have something for this already, I would like to use the Oracle one.
    Thank you.

    Hi,
    Actually i) is done for you automatically. If you schedule a job to run periodically and the last run runs over the next start date then dbms_scheduler will automatically skip the next run and go to the next one. dbms_scheduler never has two instances of the same job running at the same time.
    So you don't need any extra concurrency control. If you do need concurrency control, dbms_lock offers a simple way to protect access to a resource (e.g. if only one session should be accessing a table at a time).
    Finally if you just need e-mail sent when a job fails you can use an Oracle-provided utility on the Scheduler home page
    http://www.oracle.com/technology/products/database/scheduler/index.html
    Look for the job notification package under Scheduler Utilities which will make it very easy to send e-mail when your job fails.
    If you have any further questions, feel free to ask !
    -Ravi

  • Execute script on wallpaper change event

    My wallpaper is set to change every 30 mins.
    How do I catch the wallpaper change event and execute a script when the wallpaper changes?
    -R

    Your understanding/use of with timeout in incorrect.
    with timeout tells AppleScript how long to wait for applications to execute the specified commands. Therefore in your example:
    with timeout of 0 seconds
    tell application "Finder" to set current_pic to desktop picture
    You're saying 'wait indefinitely for the Finder to get the current desktop picture'. Under normal circumstances that task would take a few milliseconds, at worst, so setting a timeout doesn't make much sense. You're also checking the desktop picture twice per iteration, which is approximately double the amount of work you need to do.
    Your script would be better written using an idle handler, like:
    global old_pic
    on run
      tell application "Finder" to set old_pic to desktop picture as alias
    end run
    on idle
      tell application "Finder" to set current_pic to desktop picture as alias
      if current_pic is not old_pic then
        display dialog "Desktop pattern is different"
        set old_pic to current_pic
      end if
      return 10 -- check again in 10 seconds
    end idle
    In this way the desktop picture that's current when the script is launched is stored in a global variable. For each iteration of the idle handler the script gets the then-current desktop pattern and compares it against the original (so it only gets the desktop pattern once per iteration).
    If they differ then the script posts a dialog (could be any action you want to take) and resets old_pic to reference the current desktop picture (so that next time around it compares the desktop to what we have now, not the original one when the script launched).
    Finally the return 10 tells AppleScript to check again in 10 seconds (could be any time interval you like, depending on how soon you want to detect changes).
    The ObjC solution is neater since it adds a hook into the system to call your code when the system environment changes. Not as clear/legible as AppleScript, of course, but it doesn't offer an even more elegant solution.

  • ICal failing to run applescripts: The 'Open' button does not change to 'Run', and the script file is opened but not executed on alert.

    iCal failing to run applescripts: The 'Open' button does not change to 'Run', and the script file is opened but not executed.

    Calendar (not called iCal anymore) does not include that capability any longer, apparently.  What you have to do now is go to Automator and create a Calendar Alert action.  You can add a Run AppleScript object to the action and paste in your script there, then when you save it, it will become available as a choice in the alert menu in Calendar.

  • How to change the Default login script and the USER login script in Netware3.12

    I need to cut down the disk map from Neware 3.12 in Win98 client's PC.
    please tell me
    how to change the Default login script and the USER login script in
    Netware3.12 ?
    Or is there any other ways to do this thing?
    Thanks a lot!

    On 4/6/2006 [email protected] wrote:
    > how to change the Default login script and the USER login script in
    > Netware3.12 ?
    Please repost in the discontinued.forums.
    Edison Ortiz
    Novell Product Support Forum SysOp
    (No Email Support, Thanks !)

  • Can't rename folder in main directory and changes need to be authenticated

    This just started today: I can't rename folders in my main directory, and I can't move anything in or out without authenticating. Yesterday I had remote tech support working to fix Parallels, and I suspect that the tech support guy changed a setting, but I can't find it to change it back. Ideas, anyone? Please advise.
    Thanks,
    Karen

    Select the main directory in the Finder, choose Get Info from the File menu, and give yourself Read & Write access under Sharing & Permissions.
    (43510)

  • Is there any changes in the DIAdem script between DIAdem 9.x and DIAdem 10.x ?

    Hello,
    I have got a question about DIAdem Script.
    I saw the compatibility problem described in KB.
    'Why do my DIAdem 9.1 Scripts not work in DIAdem 10?'
    Many problems were solved, but some case were not.
    So I guess there is some changes in the DIAdem script between DIAdem 9.x and DIAdem 10.x
    Thanks for your help.

    Hi supportko...
    Yes, there were a lot of new features introduced in DIAdem 10.0, and 10.1.  These are described in detail in each product's ReadMe file, and also in the Online Help under  the "Index" tab at the node "DIAdem>>New Features>>New Commands and Variables"-- you will see 2 sections there:  "Version 10.1", and "Version 10.0", showing you exactly what has changed.  In most cases there is a compatability switch whenever a new feature creates a compatability issue for scripts developed in a previous DIAdem version.  R&D works very hard to minimize the impact of new features on existing VBScript applications.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments
    Message Edited by Support on 05-02-2007 03:56 PM

  • How to do changes in Layouts setting and SAP scripts to meet requirment?

    hi SD gurus,
    Please explain me how create and work with Z output .
    where and how we do changes in Layouts setting and SAP scripts to meet the user requirments.
    pls forward func spec of Z output
    points will be rewarded
    thanx & regards

    you need ABAP skills to do this.
    basically you need:
    1) draw the layout on a piece of paper
    2) define the fields you need and find out the corresponding SAP fields
    3) check the document with the customer
    4) give this specification to the developer
    5) the developer will give you a program name and form name: place them in the message for the document.
    Roberto

  • Scripts Directory and documentXML.aspx

    Hello everyone,
    I am using numerous hyperlinks to dynamically open up new documents.  Our current system is XIr2 sp5 running .Net.
    We have installed XIR3.1 on a new system and I am trying to test out the hyperlinks.  It seems that the Scripts directory that held the documentXML.aspx was not installed on the new system.
    My questions:  Can I copy the Scripts folder from XIR2 to XIR3 and keep the documentXML functionality?  Is documentXML.aspx even supported anymore.
    Thanks -- the info is appreciated.
    Richard Puhl

    Hi Rich,
    Calling documentXML.aspx directly was never supported in XI r2.  In XI 3.x the Web Applications for both Java and dotNet were completely rewritten and the scripts folder as you knew it no longer exists.  What you should do now is modify your links to use a URL report method as outlines in Viewing Reports and Documents using URLs: [http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_url_reporting_opendocument_en.pdf|http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_url_reporting_opendocument_en.pdf]

  • Can servlets/ jsp automatically run perl scripts and executables?

    I'm a student and am new to to servlets and web programming in general.
    I need to know if it's possible to run perl scripts and executables automatically from servlets/ jsp.
    The program I am planning on creating should have a client outside a firewall that uploads perl files to a gateway machine inside the firewall, the servlet should be able to run this perl file, and then pass the resulting file as an argument to an executable, to be run by another servlet on a different server.
    I've tried looking everwhere for an answer to this and am about to revert to a cgi based approach because I'm not sure if it would work so any help/ suggestions would be much appreciated.

    Hallo,
    I think using java Runtime will help. you can do Processes that execute shell or system commands through
    Process process = Runtime.getRuntime().exec("your perl scripts here!");
    Bye

  • Creating an executable script with vi and chmod

    I have some after market packages I want to set up in my MBP Mavericks. I create a script file in iv called runada. It adds some directories to the global $PATH variable. I then change rights on the script, runada, with 'chmod a+x runada' so it becomes an execuitble. But it fails when I call runada within a shell terminal. I have seent his work in Debian I think.

    As a guess: PATH needs to be exported if you want that setting to persist after the script modifies it and exits, or you'll need to "." or "source" invoke the script.
    In any case, post a reproducer of the bash and somebody here can have a look.
    Using homebrew is another approach to rolling your own packaging (if that's where you're headed here), and there are various alternatives to that.

  • When I download a PDF, a user manual for instance, the page is black and the font is green, how do I change this to a white page and black script?

    When I download a PDF, a user manual for instance, the page is black and the font is green, how do I change this to a white page and black script?

    Try opening it with Adobe Acrobat Reader. 
    Note: Appleworks is the Apple office like application that stopped being able to run with Mac OS X 10.6.8.  If you have a question particular to 10.9, I would ask in the 10.9 (OS X Mavericks) forum.

  • Get system variable and execute a Java Script

    I'm not sure it is the appropriate forum to ask this
    question. I'm using Captivate 2 without LMS.
    I need to execute a java script that take read a system
    variable (eg. USERNAME) and opens an URL using the USERNAMe as
    parameter. The idea here is to update a database opening a specific
    URL for a specific USERNAME.
    Any one has an example to do something similar ?

    Hello All,
    Could anyone please help me with some examples or
    tutorials how I can create Java Applet to run telnet
    to UNIX and execute a shell script?
    Presumably you don't need to write the telnet code yourself (like for a class.)
    If so then you can use this...
    http://jakarta.apache.org/commons/net/
    There might be some other dependencies from other commons stuff that you will need to resolve to run it.
    Once you have that, presumably you are not telnetting back to the source of the applet. If so you will need to deal with security for the applet. Usually that means that you must sign the applet. Otherwise you will have to modify the policy file on each client machine that will run the applet.

Maybe you are looking for

  • How to use Facebook in appile tv

    How to use iphon 4s(Facebook) in appile tc

  • BT Infinity Order and INstallation Delay

    Here is my sad story of BT Infinity order.  For four weeks now I do not have any internet at home due to this problem with BT.  Original meant ot be installed on mar 27, but still no update luck. BT Order History: * MARCH 13, 2014 – Today ordered BT

  • Printing to networked HP7210 problems

    When any of the Macs in our house prints to an HP7210 that is networked through a PC a strange thing happens. It just intakes paper and spits them out blank until the paper tray is empty and then says it is out of paper. Any suggestions? The PCs all

  • QTPro opens a 1080i compressed file on WinXP OS machine, but white screen?

    I am trying to open a HDV file created on a MAC system in .mov format using Quick Time Pro under Win XP. I can open this file in MPEG-4, and DVCPRO-NTSC, and they view fine. but when I try to open the same files generated using AppleCodec 1080i, or D

  • No songs, but still 1.05 GB used up

    I cleaned off all of the songs on my ipod mini, but it still says 1.05 GB is still being used. I unplugged the ipod, and looked on it and there aren't any songs, but when I replugged it into my computer, it still said 1.05 GB were used.