LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-07-2013, 05:45 AM   #1
reza_zah1991
Member
 
Registered: Mar 2013
Location: Qom , Iran
Distribution: opensuse,lubuntu
Posts: 32

Rep: Reputation: Disabled
Thumbs up interActive to offline shellScript


hi folks
i'm write these line in a file with name "qlite.sql"
Code:
create table tb1(name varchar(20),family varchar(20),age integer);
insert into tb1 values("reza","aghazade",22);
insert into tb1 values("amin","aghajani",20);
.mode column
.separator :
.header on
select * from tb1;
& do interActive shellScript in offline Script
Code:
sqlite3 myDB < sqlite.sqlcat
i want to use this bellow code like above,,but it didn't work
Code:
passwd=123098
su root <<EOF
>$passwd
EOF
but it did't work
can enbody know about that?
how to do that?
 
Old 07-07-2013, 06:02 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
You're reading the wrong input file on your second command and you're just opening a new session for root and not actually executing any sqlite3 command.

I think there are basic points you don't read yet so I suggest you read the bash manual (man bash) and some basic scripting tutorials online like Bash Guide for Beginners.

Try to read some docs about sqlite3 and su as well.
 
Old 07-07-2013, 09:06 AM   #3
reza_zah1991
Member
 
Registered: Mar 2013
Location: Qom , Iran
Distribution: opensuse,lubuntu
Posts: 32

Original Poster
Rep: Reputation: Disabled
Thumbs up

i know below code must create a new session
but after do that,,current user is not root
Code:
passwd=123098
su root <<EOF
>$passwd
EOF


---------- Post added 07-07-13 at 03:07 PM ----------

i know below code must create a new session
but after do that,,current user is not root
Code:
passwd=123098
su root <<EOF
>$passwd
EOF
IDON'T KNOW WHY?
 
Old 07-07-2013, 10:43 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by reza_zah1991 View Post
i know below code must create a new session
but after do that,,current user is not root
Code:
passwd=123098
su root <<EOF
>$passwd
EOF


---------- Post added 07-07-13 at 03:07 PM ----------

i know below code must create a new session
but after do that,,current user is not root
Code:
passwd=123098
su root <<EOF
>$passwd
EOF
IDON'T KNOW WHY?
Because stdin is not suitable for passwords - su/sudo requires a secure channel for its password so it opens /dev/tty for use with prompts and password input.

Putting a password in a script is bad security... and putting roots password in a file really really bad.

There are utilities around to do this - that was what the "expect" utility does. But misuse of it will/can expose your passwords.
 
  


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
emacs lisp: naming convention for interactive/non-interactive function pairs hydraMax Programming 6 05-31-2013 12:01 AM
[SOLVED] Of interactive and non-interactive shells. stf92 Linux - Newbie 1 10-05-2011 12:37 PM
Interactive and non-interactive shells? Tim356 Linux - Newbie 7 11-05-2008 10:32 PM
BASH - How to open an interactive script from a non interactive script..... OldGaf Programming 4 06-29-2008 04:34 PM
interactive and non-interactive shell linuxjamil Programming 3 09-03-2006 08:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:27 PM.

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