Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Saltstack commands inside bash scripts don’t work Post 303041113 by gurudewa on Friday 15th of November 2019 02:20:16 AM
Old 11-15-2019
In /home/stack/.bashrc, there is a function called salt.

Should I put the same in my bash script?
Code:
[stack@undercloud (stackrc) ~]$ cat tst.sh
#!/usr/bin/bash
 
source /home/stack/stackrc
 
echo "running"
echo $PATH
salt '*Compute-1' cmd.run 'sudo virsh list'
 
exit
[stack@undercloud (stackrc) ~]$
 
[stack@undercloud (stackrc) ~]$ ./tst.sh
running
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/stack/.local/bin:/home/stack/bin
./tst.sh: line 7: salt: command not found
[stack@undercloud (stackrc) ~]$
 
 
[stack@undercloud (stackrc) ~]$ cat .bashrc
# .bashrc
 
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
 
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
 
# User specific aliases and functions
alias c_ovs='/usr/share/cbis/undercloud/tools/ssh-overcloud.sh OvsCompute'
alias c_ovs_triple='/usr/share/cbis/undercloud/tools/ssh-overcloud.sh TripleNicOvsCompute'
alias c_sriov='/usr/share/cbis/undercloud/tools/ssh-overcloud.sh SriovPerformanceCompute'
alias c_sriov_triple='/usr/share/cbis/undercloud/tools/ssh-overcloud.sh TripleNicSriovPerformanceCompute'
alias c_flat='/usr/share/cbis/undercloud/tools/ssh-overcloud.sh FlatSriovPerformanceCompute'
alias c_dpdk='/usr/share/cbis/undercloud/tools/ssh-overcloud.sh DpdkPerformanceCompute'
alias c_dpdk_triple='/usr/share/cbis/undercloud/tools/ssh-overcloud.sh TripleNicDpdkPerformanceCompute'
alias c_avrs='/usr/share/cbis/undercloud/tools/ssh-overcloud.sh AvrsReadyCompute'
alias s='/usr/share/cbis/undercloud/tools/ssh-overcloud.sh Storage'
alias o='/usr/share/cbis/undercloud/tools/ssh-overcloud.sh Controller'
alias os='/usr/bin/openstack'
alias res='/home/stack/bin/res.sh'
function salt { source ~/venv/salt-ssh/bin/activate; salt-ssh -c /home/stack/salt/etc/salt/ --log-file /home/stack/salt/var/log/salt/ssh --no-host-keys "$@"; deactivate; }
source /home/stack/stackrc
source /var/lib/cbis/cbis_hotfix_rc
alias cbis_hotfix=/var/lib/cbis/cbis_hotfix
[stack@undercloud (stackrc) ~]$

--- Post updated at 08:20 AM ---

This is resolved.

I only had to source .bashrc in my script.

Thanks.

Last edited by vbe; 11-15-2019 at 05:26 AM.. Reason: code tags please, my last warning
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

scripts cant work correct

Hi all, Can any one help me to look on script below. My script can work correctly. For the if compare if more than 500 will go to pub.sh -stop but it go to echo $?. what happen to the $? , cant use to compare as integer??? Any one please help,urgent...thanks! #!/bin/ksh sqlplus -s... (11 Replies)
Discussion started by: jaseloh
11 Replies

2. UNIX for Dummies Questions & Answers

Why do basic unix commands not work in BASH

Why do basic unix commands such as "ls" not work in "BASH" mode?? I am frustrated!! (10 Replies)
Discussion started by: PixelLover
10 Replies

3. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

4. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

5. Shell Programming and Scripting

Changing the Bash Scripts to Bourne Scripts:URGENT

Hi, I have to write a program to compute the checksums of files ./script.sh I wrote the program using bash and it took me forever since I am a beginner but it works very well. I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies

6. Shell Programming and Scripting

$RANDOM does not work inside a shell script

Hi folks I'm coding on Ubuntu 9.04 standard shell. I'm writing a script that needs to generate a random number at some point of its execution. When I do echo $RANDOMas a command inside shell, I clearly get some randomly generated number However when I do i=`$RANDOM` echo $ior even... (14 Replies)
Discussion started by: ksk
14 Replies

7. Shell Programming and Scripting

Bash scripts as commands

Hello, the bulk of my work is run by scripts. An example is as such: #!/bin/bash awk '{print first line}' Input.in > Intermediate.ter awk '{print second line}' Input.in > Intermediate_2.ter command Intermediate.ter Intermediate_2.ter > Output.out It works the way I want it to, but it's not... (1 Reply)
Discussion started by: Leo_Boon
1 Replies

8. Shell Programming and Scripting

Why doesnt if inside a while loop work ?

I am looping through a file in bash and performing some operations on it. Here is the code. cat test.dat - One Two Three Case 1: With if inside while loop Output: One file found :) ------------------ isn't it supposed to print following output !!! one (3 Replies)
Discussion started by: qwarentine
3 Replies

9. Shell Programming and Scripting

Why commands inside bash script lost effectiveness?

Hi, I have a bash script to run many system commands on CentOS machine, but I am puzzled by some commands had no effect on parent environment. For example, I want to refresh the desktop xdg menu when some processes added or deleted items from desktop xdg menu. If I run "killall gnome-panel"... (4 Replies)
Discussion started by: hce
4 Replies

10. Shell Programming and Scripting

Work with file inside zip

Hi all, I`m trying to find 3 files from all zip files in a directory (and its all its subdirectories) recursively, and concatenate them correspondingly along with the filename (possibly path of that file from current directory). Suppose I have 3 zips a123.zip a234.zip a456.zip ... (2 Replies)
Discussion started by: senhia83
2 Replies
ssh-http-proxy-connect(1)					   User Commands					 ssh-http-proxy-connect(1)

NAME
ssh-http-proxy-connect - Secure Shell proxy for HTTP SYNOPSIS
/usr/lib/ssh/ssh-http-proxy-connect [-h http_proxy_host] [-p http_proxy_port] connect_host connect_port DESCRIPTION
A proxy command for ssh(1) that uses HTTP CONNECT. Typical use is where connections external to a network are only allowed via a proxy web server. OPTIONS
The following options are supported: -h http_proxy_host Specifies the proxy web server through which to connect. Overrides the HTTPPROXY and http_proxy environment variables if they are set. -p http_proxy_port Specifies the port on which the proxy web server runs. If not specified, port 80 is assumed. Overrides the HTTPPROXY- PORT and http_proxy environment variables if they are set. OPERANDS
The following operands are supported: http_proxy_host The host name or IP address (IPv4 or IPv6) of the proxy. http_proxy_port The numeric port number to connect to on http_proxy_host. connect_host The name of the remote host to which the proxy web server is to connect you. connect_port The numeric port number of the proxy web server to connect you to on http_proxy_host. EXAMPLES
The recommended way to use a proxy connection command is to configure the ProxyCommand in ssh_config(4) (see Example 1 and Example 2). Example 3 shows how the proxy command can be specified on the command line when running ssh(1). Example 1 Setting the proxy from the environment The following example uses ssh-http-proxy-connect in ssh_config(4) when the proxy is set from the environment: Host playtime.foo.com ProxyCommand /usr/lib/ssh/ssh-http-proxy-connect playtime.foo.com 22 Example 2 Overriding proxy environment variables The following example uses ssh-http-proxy-connect in ssh_config(4) to override (or if not set) proxy environment variables: Host playtime.foo.com ProxyCommand /usr/lib/ssh/ssh-http-proxy-connect -h webcache -p 8080 playtime.foo.com 22 Example 3 Using the command line The following example uses ssh-http-proxy-connect from the ssh(1) command line: example$ ssh -o'ProxyCommand="/usr/lib/ssh/ssh-http-proxy-connect -h webcache -p 8080 playtime.foo.com 22"' playtime.foo.com ENVIRONMENT VARIABLES
HTTPPROXY Takes the http_proxy_host operand to specify the default proxy host. Overrides http_proxy if both are set. HTTPPROXYPORT Takes the http_proxy_port operand to specify the default proxy port. Ignored if HTTPPROXY is not set. http_proxy URL format for specifying proxy host and port. EXIT STATUS
The following exit values are returned: 0 Successful completion. 1 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWsshu | +-----------------------------+-----------------------------+ |Interface Stability |Stable | +-----------------------------+-----------------------------+ SEE ALSO
ssh(1), ssh-socks5-proxy-connect(1), ssh_config(4), attributes(5) SunOS 5.11 24 Oct 2001 ssh-http-proxy-connect(1)
All times are GMT -4. The time now is 12:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy