source command not found in sh shell

前端 未结 12 706
温柔的废话
温柔的废话 2020-11-28 02:14

I have a script that uses sh shell. I get an error in the line that uses the source command. It seems source is not included in my

相关标签:
12条回答
  • 2020-11-28 02:47

    source is a bash built-in command so to execute source command, you can log in as Root.

    sudo -s source ./filename.sh

    0 讨论(0)
  • 2020-11-28 02:51

    /bin/sh is usually some other shell trying to mimic The Shell. Many distributions use /bin/bash for sh, it supports source. On Ubuntu, though, /bin/dash is used which does not support source. Most shells use . instead of source. If you cannot edit the script, try to change the shell which runs it.

    0 讨论(0)
  • 2020-11-28 02:52

    The source command is built into some shells. If you have a script, it should specify what shell to use on the first line, such as:

    #!/bin/bash
    
    0 讨论(0)
  • 2020-11-28 02:53

    I faced this error while i was trying to call source command from #Jenkins execute shell.

    source profile.txt or source profile.properties

    Replacement for source command is to use,

    . ./profile.txt or . ./profile.properties

    Note: There is a space between the two dots(.)

    0 讨论(0)
  • 2020-11-28 02:55

    The source builtin is a bashism. Write this simply as . instead.

    e.g.

    . $FILE
    
    # OR you may need to use a relative path (such as in an `npm` script):
    
    . ./$FILE
    

    https://wiki.ubuntu.com/DashAsBinSh#source

    0 讨论(0)
  • 2020-11-28 02:59

    Bourne shell (sh) uses PATH to locate in source <file>. If the file you are trying to source is not in your path, you get the error 'file not found'.

    Try:

    source ./<filename>
    
    0 讨论(0)
提交回复
热议问题