Results 1 to 6 of 6

Thread: tcsh and commands

  1. #1
    Join Date
    Jan 2011
    Beans
    21

    tcsh and commands

    Hello,

    I just recently installed Ubuntu for our server, and I had a question about using tcsh.

    I'm trying to run a script of commands and the first line of my script is:

    #! /bin/tcsh -f
    I chmod +x my script, but when I type the name of my script at the command line i get this message:

    myscript: Command not found.
    the only way my script will work is if I type:

    tcsh myscript
    Only then, will myscript execute its set of commands.

    I would like to be able to type the name of scripts without having to type tcsh at the beginning, each time. Is there a way to do that?

    Your help would greatly be appreciated.

    Thanks,

    Cor

  2. #2
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: tcsh and commands

    The script would have to be in the path.

    Instead of running:
    Code:
    tcsh myscript
    You can just run this if you are in the same directory as the script:

    Code:
    ./myscript
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  3. #3
    Join Date
    Jan 2011
    Beans
    21

    Re: tcsh and commands

    that is right, i discovered the ./myscript trick just recently. I forgot to mention that in my post.

    i am a recent convert to ubuntu.

    i have used redhat in the past, and used simiarl shell scripts via tcsh. but i don't recall ever having to always type "./" before the name of myscript to execute it.

    should i set up something in my .cshrc file to to get around this?

    thanks,

    cor

  4. #4
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: tcsh and commands

    The . just means to look in the current directory.

    Unless the place where your scripts are stored is in the $PATH variable, then you have to use the full path to execute them.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  5. #5
    Join Date
    Jan 2011
    Beans
    21

    Re: tcsh and commands

    Charles,

    Thanks for the reply. I set up a path in my .cshrc file where I will store my scripts, and that did the trick.

    Thanks again,

    cor

  6. #6
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: tcsh and commands

    Glad you got it working. Don't forget to mark the thread as solved from thread tools at the top.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

Bookmarks

Posting Permissions

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