Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Simple shell script to execute 2 unix cmds

  • 26-04-2007 10:13PM
    #1
    Registered Users, Registered Users 2 Posts: 264 ✭✭


    Hi All

    I'm having problems creating a simple shell script to execute 2 unix commands.

    Basically, the commands are:

    > cleartool setview myview
    > source /vobs/mydir/...

    Setting the clearcase view is causing the problem, this command seems to launch a subshell (i.e. the SHLVL environment variable is incremented), so the 2nd command does not get executed until I exit the subshell.

    How do I get the 2nd command to execute in the subshell?

    btw....I use tcsh

    Any help with this would be great!

    Cheers!


Comments

  • Registered Users, Registered Users 2 Posts: 6,342 ✭✭✭OfflerCrocGod


    Change the ordering of the commands?


  • Registered Users, Registered Users 2 Posts: 264 ✭✭MartyM


    I cant, in order to access the /vobs... directories I must have my clearcase view set...


  • Registered Users, Registered Users 2 Posts: 6,342 ✭✭✭OfflerCrocGod


    I've never seen those commands before so I'm guessing here but can you run it in the background ( & ) or maybe there is a way to pipe the second command into the new shell cmd1 < cmd2 I suppose ; wont work as that's the same thing as putting the two commands on different lines.


  • Registered Users, Registered Users 2 Posts: 264 ✭✭MartyM


    Thanks for the suggestions!....yeah, I tried piping the commands but for some reason it only executed one of them...the 2nd I think. Was doing this at work, so dont remember the exact details....i've tried so many things at this stage...


  • Registered Users, Registered Users 2 Posts: 6,655 ✭✭✭daymobrew


    I remember this dilemma when I used to work with ClearCase, when it was still Rational and had some corny marketing slogan.

    I searched the knowledge base on ibm.com and found one article that suggested using startview instead of setview and one that uses the '-exec' parameter.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 264 ✭✭MartyM


    daymobrew wrote:
    I remember this dilemma when I used to work with ClearCase, when it was still Rational and had some corny marketing slogan.

    I searched the knowledge base on ibm.com and found one article that suggested using startview instead of setview and one that uses the '-exec' parameter.


    Thanks Daymobrew and everyone else!!!

    Ideally I wanted to remain in the clearcase envornment and have the equivalent of the following from the command line:

    > cleartool setview myview
    [myview] > source /vobs/setup

    [myview] > Then continue working
    [myview] > within the clearcase environment
    [myview] > and within the subshell spawned by the cleartool command


    However, I found this workaround on the same site as you have highlighted:

    http://www-1.ibm.com/support/docview.wss?rs=984&context=SSSH27&dc=DB520&uid=swg21119859&loc=en_US&cs=UTF-8&lang=en&rss=ct984rational

    The following script allows me to set my view, source the vob and execute a
    command within the clearcase environment.

    The downside is that I dont remain in the clearcase environment.

    The upside is that I dont have to "enter" the clearcase environment when using the alias! :)

    #!/bin/tcsh
    
    # This script allows the user to run the 'extractinfo' command from the vobs
    # without having to set their view or source /vobs/setup manually.
    
    # The script is executed with the following command:
    #
    #	cleartool setview -exec ~<user>/bin/source_extractinfo.sh myview
    # 
    # OR with the alias 'lminfo' defined in ~<user>/.aliases
    
    # Source vobs so that the extractinfo utility can be used to extract LM information
    source /vobs/setup
    
    # Prompt the user to enter the location and name of the LM
    echo "Enter: /path/to/loadmodule"
    
    # Read user input from stdin
    set LM = $<
    
    echo "Performing 'extractinfo' on the following LM: $LM..."
    
    # Run the 'extractinfo' command to extract the LM info
    extractinfo $LM
    


Advertisement