Here I have one script which exporting some necessary path in Linux. After running this script I have to run some other scripts.
I have two scripts
1 imp
The difference between the two invocations is that ./import.sh
is executing import.sh as a program, and . ./import.sh
is evaluating it in your shell.
If "import.sh" were an ELF program (a compiled binary, not a shell script), . ./import.sh
would not work.
If import.sh had a shebang at the top (like #!/bin/perl
), you'd be in for a nasty surprise and a huge number of error messages if you tried to do . ./import.sh
- unless the shebang happened to match your current shell, in which case it would accidentally work. Or if the Perl code were to somehow be a valid Bash script, which seems unlikely.
. ./import.sh
is equivalent to source import.sh
, and doesn't require that the file have the execute bit set (since it's interpreted by your already-running shell instead of spawned via exec
). I assume this is the source of your error. Another difference is that ./import.sh
runs in the current shell instead of a subshell, so any non-exported environment variables will affect the shell you used for the launch!
So, they're actually rather different. You usually want to ./import.sh
unless you know what you're doing and understand the difference.