K
K
Konstantin2022-04-20 23:47:05
linux
Konstantin, 2022-04-20 23:47:05

How to correctly pass the password and login to the bash script as an argument?

How to correctly pass the password and login to the bash script as an argument?
For example, to connect to a database

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Adamos, 2022-04-21
@Adamos

If this is access to the site database, then parse from its own files. For example, here is Bitrix:

#!/bin/sh
doc_root=~/public_html
dbconn=$doc_root/bitrix/php_interface/dbconn.php

host=`cat $dbconn | grep DBHost | sed 's/.*"\(.*\)".*/\1/'`
username=`cat $dbconn | grep DBLogin | sed 's/.*"\(.*\)".*/\1/'`
password=`cat $dbconn | grep DBPassword | sed 's/.*"\(.*\)".*/\1/'`
database=`cat $dbconn | grep DBName | sed 's/.*"\(.*\)".*/\1/'`

V
Victor Taran, 2022-04-21
@shambler81

#!/bin/bash
echo $0
echo $1
echo $2
echo $3

We start
./myscript 5 10 15
Output
fb5f9fb80361a4083e31d7225fa3cdbf.png
more options here
https://habr.com/ru/company/ruvds/blog/326328/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question