Results 1 to 6 of 6

Thread: path not working when executing from script...

  1. #1

    Default path not working when executing from script...

    Hello,
    Upon upgrading to suse11.2, I've noticed a reoccurring problem.

    I use tcsh. When I execute by hand a command that is in my path...located in say "~/bin/myscript"....the command executes without an issue. I don't need to use the absolute path "~/bin/myscript", I can simply type the command "myscript" since the path "~/bin" is in my .tcshrc file.

    When I execute the same command from a script, I get a "command not found" error. A similar issue is when I use the absolute command, but a library necessary the programs' execution is defined within my .tcshrc file. I'll get a library not found error.

    I didn't have this issue with earlier versions of suse.

    Thanks for any help,
    Paul

  2. #2

    Default Re: path not working when executing from script...

    Additional info that I just realized is relevant:
    The system is a cluster with nodes nfs-mounting user directories from the server's /home/ directory. I submit jobs via a ssh command such as " ssh mymachine myscript".

    When I run "ssh mymachine 'which ls' " I get back the path "/bin/ls" like I should. If I run "ssh mymachine 'which myscript' ", I get a command not found error. If I run "which myscript" I get the correct path.

    As mentioned, all machines use the same .tcshrc file because they all share the same nfs mounted directory.

  3. #3
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,729

    Default Re: path not working when executing from script...

    Reading man ssh I found following:
    If command is specified, it is executed on the remote host instead of a login shell.
    which is about the command parameter in your ssh call (the "which ls" or the name of your executable script).
    and:
    PATH
    Set to the default PATH as specified when compiling ssh .
    and I doubt that ssh is compiled while ~/bin/myscript was one of the items in the PATH environment variable.

    And when it executes that command it nowhere says that it does so using any shell at all.
    Henk van Velden

  4. #4

    Default Re: path not working when executing from script...

    Thanks for the reply.

    I have been running the same scripts since suse10.0 and have only recently had this issue.

    Short of reinstalling ssh on all my nodes, do you have a suggested fix.

    Right now, as a work around, I use a wrapper script with a explicitly defined shell.

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,729

    Default Re: path not working when executing from script...

    I can not tell why it worked in 10.0 where it shoud not work also

    For a solution look in that man page. Browse a bit, there are several places where adding something to a PATH is mentioned, but I do not think I should read them all where you can do this yourself. Also I do not use tcsh here for testing.
    Henk van Velden

  6. #6

    Default Re: path not working when executing from script...

    As a follow-up, this was my eventual solution.

    I created a wrapper script that explicitly defined the shell I needed. So instead of executing "ssh myscript", I'd make a wrapper script "mywrapper" that has the shell information necessary for my target executable.

    mywrapper:
    #!/bin/tcsh
    myscript

    So my final execution is "ssh ~/pathtofile/mywrapper"

    Still a mystery why this seemed unnecessary for previous releases.

Tags for this Thread

Posting Permissions

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