-bash: ./setantenv.sh: Permission denied - sap-commerce-cloud

I am trying to install hybris software on my mac os system and my system have the prerequisites like 64 bit os, 4 mb…ram…..etc. To run ant command I need to set up a ant environment first. There is a file called setantenv.sh file in my platform folder. In mac terminal I am in platform folder and typing ./setantenv and pressing enter. I am getting the following error. I tried different commands like chmod +x setantenv.sh or chmod 755 platform, BUT I could not succeed. After the successful environment setup only I can run my ant clean all command
-bash: ./setantenv.sh: Permission denied
Please help me with each steps to solve this issue. thanks

First off, you might just be able to fix it by setting the executable bit:
chmod a+x setantenv.sh
But I am also not sure if you are doing the correct call. You need to source the setantenv.sh file, so you need to do:
. ./setantenv.sh
(the leading "." is the source command and then you point to the file that you are sourcing)
So effectively, the setantenv.sh file doesn't really need the executable bit.
The errors you get happen because you have an older version of ant in your current system, the setantenv.sh will point your terminal to the correct one (that is shipped with each hybris version and resides in $HYBRIS_HOME/bin/platform)
So once you do it right, that error should disappear.
Note that you need to do this . ./setantenv.sh every time you open a new terminal.
Hope that helps!

There are 3 steps to getting this to work.
Navigate to hybris/bin/platform
1) Execute the command 'chmod 777 setantenv.sh'
2) In the terminal, type 'bash' and press enter. This will take you to bash prompt.
3) Type '. ./setantenv.sh'.
These 3 steps will work.
Cheers

I fix it by removing the if condition at the beginning.
Replace your setantenv.sh with below bash code.
PLATFORM_HOME=`pwd`
export PLATFORM_HOME
export ANT_OPTS="-Xmx512m -Dfile.encoding=UTF-8"
export ANT_HOME=$PLATFORM_HOME/apache-ant-1.9.1
chmod +x "$ANT_HOME/bin/ant"
chmod +x "$PLATFORM_HOME/license.sh"
export PATH=$ANT_HOME/bin:$PATH
$ > chmod a+x setantenv.sh
$ > . ./setantenv.sh

Related

why does ./ not work as a directory? [Linux]

I'm trying to install NET. 6.3 on my chromebook with Linux but when I try to execute
./dotnet-install.sh -c Current
in the Linux Terminal it always gives me this error:
-bash: ./dotnet-install.sh: No such file or directory
Any way around it/any fix for it?
I have done sudo -i so I got full permission and I have put the file I'm trying to execute in a lot of folders including my Linux folder.
Any help is appreciated!
I suppose you should:
chmod +x ./dotnet-install.sh
./dotnet-install.sh -c Current
or
/bin/bash dotnet-install.sh -c Current
There are two ways to execute a script on a UNIX/Linux platform:
Either you make the script executable, as explained in the other answer.
Either you use the sh or other relevant command for launching it, I prefer this way of working.
So, I would propose you to launch the following command:
sh ./dotnet-install.sh -c Current
Have you tried the pwd command to see on which path are you working on?
Then try to ls | grep dotnet-install in the current directory, if there isn't output you have to change directory.
Probably you are trying to execute the dotnet-install.sh in a wrong directory, i suppose.
Another way is to get file trough wget command on terminal to be sure you download the file in the correct directory.
Regards

Unable to access jarfile in Ubuntu, even with full permissions?

I'm fairly new to Linux/Unix and I'm having trouble making a shell script run an executable jar file. This is the content of my shell script start.sh:
java -Xmx4096 -Xms4096 -jar "/home/user/Documents/Mserver/fserver.jar"
The error I get is
Error: Unable to access jarfile /home/user/Documents/Mserver/fserver.jar
What I've tried:
I tried running the commands
chmod u+x /home/user/Documents/Mserver/start.sh
chmod u+x /home/user/Documents/Mserver/fserver.jar
chmod -R 777 /home/user/Documents/Mserver
To give all of my files read, write, and execution permissions
Also, I originally just had the name of the jar file in the shell script and not the whole path it was in. After being told that adding the path may fix the problem, I added it but nothing changed.
When I was looking at another similar question on the site I saw someone was having the same problem with a pearl script and it was because of something with a configuration file, but I have no idea if this is relevant to me at all.
I'm a newbie and I have no idea what to try next, so please let me know if you've noticed anything wrong with how I'm doing this, have any suggestions, or think I left out any important details.
EDIT: When running the command
ls -l /home/user/Documents/Mserver/fserver.jar
I get the result:
-rwxrwxrwx 1 user user 4883911 Dec 12 17:15 /home/user/Documents/Mserver/fserver.jar
And when changing my file to
path="$HOME/Documents/Mserver/fserver.jar"
java -Xmx4096 -Xms4096 -jar $path
I get still get the error:
Error: Unable to access jarfile /home/user/Documents/Mserver/fserver.jar
Also, another thing I forgot to note is when I navigate to the directory where the jar file is and run the command
java -Xmx4096 -Xms4096 -jar fserver.jar
It works.
Add the following line into your shell script:
path="$HOME/Documents/Mserver/fserver.jar"
java -Xmx4096 -Xms4096 -jar $path
Try to start the file with the absolute path you use in that script but with that method you know otherwise works.
(so navigate to your directory and run the command you know works:
java -Xmx4096 -Xms4096 -jar fserver.jar
but with that absolute path you used in that script. In that case:
$HOME/Documents/Mserver/fserver.jar
)
If that does not work, then the reference is probhably bad.

Modifying PATH in Linux

I recently installed linux, been trying to append stuff to my PATH but it doesn't seem to work. Here is my config file (~/.bashrc)
echo "Executing .bashrc ..."
export PATH=$PATH:/home/user/files/scripts
For example: i have a file "script_name.sh" in ~/scripts. I type "script_name" in a terminal and it gives an error: script_name: command not found. Am i missing something here?
try chmod +x myscript.sh
this will make the script executable.
On GNU/Linux (ie Unix), execution permission is require for execution.
(+x = make it executable)

cp command won't run if executed from shell script

i have very simple shell script
#!/bin/bash
cp -rf /var/www/ksite/app2/* /var/www/ksite/app
echo "----"
echo "done"
but seems cp command fails
if i execute
cp -rf /var/www/ksite/app2/* /var/www/ksite/app
from terminal everything work ok. Can someone tell me how to include cp in shell script?
Thanks
We seem to have doubt as to how this script fails. If there is no error message then this is a strange one. I suggest:
On the command line (which works), do a which cp
Whatever the reply, then copy that and use it as the cp in the script (e.g. /bin/cp)
Check the widcard expansion, run your script with bash -x script-name and see if you get what you expect.
echo $? after the copy in the script - if it is zero then it (thinks it) worked.
Do a ls -ld /var/www/ksite/app from your script, maybe someone set a symbolic link?
If it still fails, source the script from the command-line and see if that works . script-name
Double check that the copy did actually fail! (maybe that should be step 1.)
Make sure you really have bash at /bin/bash. I think a batter hash bang is:
#!/usr/bin/env bash
This uses the env command to locate the bash binary and set the environment.
I had similar problem. What helped me:
I used windows and putty to write script, so I had \r\n at the end of lines. Be sure, you have only \n symbol.
I copied files and the only way it worked for me at script was cp <source_dir>/fileName <dest_dir>/fileName whereas at command line cp <source_dir>/fileName <dest_dir> worked well too.
Just covering all the bases .. do the permissions vary between the excutions .. i.e. do you execute one with sudo/root privileges, the other as user (unlikely, but thought I'd ask since we don't know what the exact error is)
Similar issue to Vladmir where the script was created in Windows. I created a new file "my_bash_script.sh" in the linux environment using VIM, then read the contents of my script into the file:
:r file_made_in_windows.sh
Then I saved, closed, then set the file as executable:
chmod 744 my_bash_script.sh
From there, I ran the script:
./my_bash_script.sh
...and it worked. What a weird issue. I was confounded for a moment.

How to fix path variable in bash on Mac OSX Snow Leopard

This might be a noob question, but I need help. I screwed up my terminal by trying to alter my path variable using the following command:
$ sudo nano .profile
Before I did that, if I were to type:
$ echo $PATH
I would get: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
When I opened .profile in nano it told me that the file didn't exist. I figured that made sense, since I had never edited this file before. I proceeded to enter a path to a directory I was using for a php framework and saved the file.
After I saved the file, I noticed that none of my bash commands are working. Now I can't do anything from the terminal. I can't even edit .profile in nano because it says -bash: nano: command not found
I'm clearly new to working with the terminal. I feel completely lost. Please provide some guidance on how to restore the terminal to working condition.
Use absolute paths.
$ /usr/bin/sudo /usr/bin/nano .profile
If you add something to a path, never just do
PATH=/path/to/something
instead do
PATH=$PATH:/path/to/something
By the way, you shouldn't/don't have to use sudo to edit your own file, such as .profile. Use sudo only when you need to edit the file which doesn't to belong to your account.
I had the same problem!
The way I solved was writing the follow command in the terminal:
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/usr/local/git/bin:/usr/X11/bin
Hope it can be useful for you

Resources