Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Comments on How to give password in shell script?

Post

How to give password in shell script?

+2
−4

That's my Bash script:

#!bin/sh

cd qpixel
sudo systemctl enable mysql
mysql -u root -p
rails s

When it executes the line mysql -u root -p it will ask for password. To do so, I have tried with echo and print, but none of them works.

How can I input a password?

Related question I found in SO. Answers of SO didn't help me either.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

Kinda difficult to know what you want to do based on what you're writing... do you want to get prompt... (1 comment)
Of course the linked SO answer will work with sudo (1 comment)
Of course the linked SO answer will work with sudo

Skipping 2 deleted comments.

elgonzo‭ wrote over 3 years ago · edited over 3 years ago

My apologies. I am apparently too dumb to read a question. Your question is not about the sudo line in your script, obviously. So please ignore this comment thread and its title. I don't know why i fixated onto sudo. Am i allowed to blame my cat? ;-)