Find the answer to your Linux question:
Results 1 to 6 of 6
Hello, I need some direction on a small scripting question. I've been doing some development and storing the code on a network drive with multiple user access. My development is ...
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    3

    print message when changing directories

    Hello,

    I need some direction on a small scripting question. I've been doing some development and storing the code on a network drive with multiple user access. My development is getting complex enough that it is time to set up a svn repo for it. I would like to set up a little script (if possible) that prints a message/reminder to whomever is accessing the code directory stating that the code is ultimately stored in svn and any changes need to be checked in, etc. Is there a way to have linux print a message to the screen based on a 'cd /specific_dir/' command? So far google is mum on the topic. Using Debian and bash shell. Thanks.

  2. #2
    Linux Newbie
    Join Date
    Apr 2007
    Posts
    119
    My opinion if you want it is, send an e-mail to all users telling them that at XX time on XX date, the code will be moved to the SVN server and will no longer be available on the network drive. Submit all changes before then to have them incorporated.

    As for your question, I cannot think of a way to do it.

  3. #3
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    121
    Quote Originally Posted by HeberG View Post
    Is there a way to have linux print a message to the screen based on a 'cd /specific_dir/' command?
    Well, the "usual" thing to do would be to leave a file called README with those sorts of instruction in, but I guess you could do that if you created a wrapper for bash and parsed each line for the 'cd /whatever/' command, then you could spit out what you want. Just remember to pass everything to/from bash, of course!

  4. #4
    Just Joined!
    Join Date
    Feb 2008
    Posts
    17

    wrapper

    rename /bin/cd to /bin/cd.orig

    create /bin/cd
    and give execute permissions.

    You can put whatever you want in /bin/cd as long as you call cd.orig $1

    Probably execute cd.orig $1, and then check `pwd` with your directory location.

    But for your need, the best thing is to delete that directory as soon as the repo is ready!

  5. #5
    Just Joined! jippie's Avatar
    Join Date
    May 2006
    Location
    Eindhoven, the Netherlands
    Posts
    76
    Sorry, I think changing system binaries (like cd) is always an extremely bad idea.

    Defining a command alias in the .profile or /etc/profile is a better way if this is the way you want to go.

    The 'cd' command is a (bash) shell built in command anyway, so changing the /bin/cd binary won't work.


    Quote Originally Posted by prasadae31 View Post
    rename /bin/cd to /bin/cd.orig

    create /bin/cd
    and give execute permissions.

    You can put whatever you want in /bin/cd as long as you call cd.orig $1

    Probably execute cd.orig $1, and then check `pwd` with your directory location.

    But for your need, the best thing is to delete that directory as soon as the repo is ready!

  6. #6
    Just Joined! jippie's Avatar
    Join Date
    May 2006
    Location
    Eindhoven, the Netherlands
    Posts
    76
    BTW: The challenge you have with printing a warning message based on a cd-command, is that you'll have to manage the use of $VARIABLES ~ . .. // \ in your little script correctly....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...