0

For automating access credentials, I have access keys in Excel file in some location. now I need to read password keys in rows and columns from this file using shell script and login to a specific website. can someone help me with this?

Thanks & Regards Francis

2 Answers 2

0

A MS-Excel file is a binary file. You need a particular tool to open it, e.g. MS-Excel.

Or, you can program using some module/library to handle office files, like java,Perl or python, and then call your program in a shell script. How to read excel file in shell script

You can, however, turn it into a text file, E.g. csv, so that some command-line text processing tool can read from it, for example, awk.

To login to a website, or call some REST endpoint you may make use of curl.

Sign up to request clarification or add additional context in comments.

Comments

0

Read file

You can using libreoffice to read xls or xlsx file, and convert to csv file.

# it will generate a same name csv file
libreoffice --headless --convert-to csv foo.xlsx

Get nth row

# Get 10th line of foo.csv (row 10)
CSV=$(cat foo.csv | sed -n "10p")

Parse csv file

And you can parse the csv file, there are have several way to do.
csvtool, regex, ...etc.

Here is regex way. Format grep -oP <regex>

CSV='9,"foo,bar",12'

regex='(?:,|^)("(?:(?:"")*[^"]*)*"|[^",]*)'
matches=$(echo $CSV | grep -oP $regex)
echo "$matches"

# 9
# ,"foo,bar"
# ,12

I'm not sure why match include comma, but it can remove easily.

The rest is up to you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.