Luca Luca - 2 months ago 14
Linux Question

Linux, BASH launch command with special char

I must implement a deploy script that launches command by special char from specific user.

The command that I must launch is:

cd /path
. ./setantenv.sh


I am trying to launch the command with this syntax:

su - USER -s /bin/bash -c 'cd /PATH/ && . ./setantenv.sh'
su - USER -s /bin/bash -c 'cd /PATH/ && ant clean all'


But I've got a problem with
. ./setantenv.sh

Answer

In order to configure the environment for your subsequent ant command, you have to include the ". ./setantenv.sh" inside your second call. Both calls result in independent bash processes that dont share their specific environment.

try this:

su - USER -s /bin/bash -c 'cd /PATH/ && . ./setantenv.sh && ant clean all'
Comments