I am trying to run a script called install.sh as follows:
I get a jar file, and extract it using the command:
unzip filename.jar -D path/to/files
then I navigate to that directory where I extracted the files, and run the command:
sh install.sh
(where install.sh is one of the files that has been extracted in that directory using the above unzip command.)
running this command gives me an error:
'nstall.sh: command not found.'
among other errors in the script ( from that portion of the script that should not even be executed, which is really weird).
However, instead of unzipping the jar file, if I just copied the same install.sh file to that folder, and ran the 'sh install.sh' command, the script runs fine. This makes me think that there is something wrong with unzipping of the jar file, but not sure. I am out of ideas on this. Any help would be appreciated.
---------- Post updated at 04:31 PM ---------- Previous update was at 04:03 PM ----------
As I said the script runs fine if I just copied the file install.sh and ran that command. It works fine even if I extracted the file from jar, deleted it, and brought it back, and then ran that command ( sh install.sh). It is only if I run that command directly after extracting it from the jar, do I get the error.
Running the above command gives the following output:
[oracle@vmhealthedb02]$ sh -x ./install.sh
+ $'\r'
: command not found2:
++ echo ./install.sh
++ awk -F install.sh '{print $1}'
+ packgeDir=$'./\r'
+ currDir=$'/home/oracle/hin-chd-capability-install-scripts-1.1.0-SNAPSHOT\r'
+ $'\r'
: command not found6:
+ cd $'./\r\r'
: No such file or directory/
+ $'\r'
: command not found8:
'/install.sh: line 23: syntax error near unexpected token `do
'/install.sh: line 23: ` do
---------- Post updated at 03:53 PM ---------- Previous update was at 03:50 PM ----------
[/COLOR]
Yes, I do have the shell. The current shell that I am running under is ksh.
in the script as you suggested.. and still get the same errors...
I also tried running with the entire path:
sh /abc/efg/install.sh
but no luck with that either...
---------- Post updated at 01:16 PM ---------- Previous update was at 01:15 PM ----------
I tried using the correct shebang as you suggested:
#!/bin/bash
but got no success with that.
---------- Post updated at 01:20 PM ---------- Previous update was at 01:16 PM ----------
Even if i pretend to make some changes in the file.... like for example opening install.sh, then putting a space somewhere in the file, then deleting that space, and saving that file,.... then it works when I type the command:
sh install.sh
It is only when I am trying to run it directly after unzipping it from the jar file, that I am not able to run it successfully.
So, is it corrupting it while unzipping it, or maybe not recognizing the file is in the directory, until I pretend to move or change it?... not sure.