LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-19-2023, 07:51 PM   #1
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Rep: Reputation: 0
Unhappy Script does not execute completely.


Hi,
I have a shell script like below.
Code:
cat sitecode_refresh.sh
#!/bin/bash

set -x

# Check if the vault password is provided
if [ -z "$1" ]; then
    echo "Usage: $0 <password>"
    exit 1
fi

scl enable python27 bash
pip2 install virtualenv=="16.7.10"
virtualenv -p /usr/bin/python2 sitecoderefresh
source sitecoderefresh/bin/activate
pip2 install -r requirements.txt
ansible-vault decrypt credential.json --vault-password-file <(echo "$1")
ansible-vault decrypt token.json --vault-password-file <(echo "$1")
python sitecode_refresh.py --spreadsheet_id="1abcxyz" --worksheet_name="Testing"
ansible-vault encrypt credential.json --vault-password-file <(echo "$1")
ansible-vault encrypt token.json --vault-password-file <(echo "$1")
deactivate
However, when I execute the script, it executes only till bash and then stops it. Please find below the execution log.

Code:
./sitecode_refresh.sh "EV:533nAI#"
+ '[' -z EV:533nAI# ']'
+ scl enable python27 bash
Can someone please guide me so that script can be executed entirely?

I literally can copy and paste each command, and I assure you 100% it works not just in script

Perhaps my second question is, can I past this in any file so that pip is available for all users?

Code:
scl enable python27 bash

Before scl command

Code:
pip
bash: pip: command not found...

After scl command

Code:
scl enable python27 bash
pip

Usage:
  pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
type pip
pip is hashed (/opt/rh/python27/root/usr/bin/pip)

which pip
/opt/rh/python27/root/usr/bin/pip
Your assistance is much appreciated.
 
Old 08-20-2023, 12:09 PM   #2
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,804

Rep: Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203
Code:
scl enable python27 bash
runs the bash command.
And the following commands run when the bash has terminated.
I think you need
Code:
scl enable python27 "bash -s '$1'" <<"_EOS_"
# Commands in bash follow
# ...
_EOS_

Last edited by MadeInGermany; 08-20-2023 at 12:13 PM.
 
1 members found this post helpful.
Old 08-20-2023, 04:36 PM   #3
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
Yeah, that is what I got from Chat GPT too. I am looking for a permanent fix for all users on that Host. Any idea?
 
Old 08-20-2023, 08:07 PM   #4
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,157

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
If you execute it one by one in sequence as per your bash script, what happens? Does it work fine?

If it it doesn't work fine, them it's not your script its on the command itself.
 
Old 08-20-2023, 10:58 PM   #5
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
@JJJCR
As written in my OP it works fine. Issue is with scl command creating a new shell.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Patching SW14.1 breaks it completely (/bin/login won't execute) ga_flyer Slackware 5 04-17-2014 11:52 PM
[SOLVED] BASH while-do script does not execute another script JoeTampa Linux - General 16 03-04-2014 10:03 AM
Script does not execute with cron Arty Ziff Linux - Newbie 14 05-23-2008 12:08 AM
PHP Script Does Not Execute Ukee Linux - Server 5 02-24-2008 08:00 PM
Trying to execute a shell-script using php but chown does not work stormrider_may Programming 15 04-11-2006 08:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration