LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-24-2015, 02:35 PM   #1
sirDexter
LQ Newbie
 
Registered: Mar 2015
Posts: 4

Rep: Reputation: Disabled
Execute script on mysql exit


Hello,

In debian I created a new user "myUser".

In /home/myUser/.profile

I added "mysql -u user -password"

So automatically after login to linux terminal the user is logged in mysql command line.

What I need to do is to exit terminal after user exit mysql, so he want have access to comand line.
 
Old 03-24-2015, 05:15 PM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 840

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
While you may probably just add logout or exit, why would you want to do that? If you want the user to only access mysql, why even create a linux account instead of just connecting remotely to the database?
 
1 members found this post helpful.
Old 03-24-2015, 05:23 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,026

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
this is what i do:
Code:
mysql -N -u schneidz -peasily-readable-password hackathon -h 192.168.1.15 -e "select distinct(npi) ,nppes_provider_first_name, nppes_provider_last_org_name, provider_type, nppes_provider_street1, nppes_provider_street2, nppes_provider_city, nppes_provider_zip, nppes_provider_state, case nppes_provider_zip when '02144' then '5'  from providers where nppes_provider_zip in ($z) and provider_type = \"$prov_type\""
so long as the router is forwarding ports correctly server-side it should query against the database directly.
 
Old 03-24-2015, 05:52 PM   #4
sirDexter
LQ Newbie
 
Registered: Mar 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
I wanted to create a tunnel through ssh using putty, but I don't know whether I can do this that way.
 
Old 03-24-2015, 06:20 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,599

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Quote:
Originally Posted by sirDexter View Post
Hello,

In debian I created a new user "myUser".

In /home/myUser/.profile

I added "mysql -u user -password"

So automatically after login to linux terminal the user is logged in mysql command line.

What I need to do is to exit terminal after user exit mysql, so he want have access to comand line.
It is simpler to create a small shell script that does just that, make it executable, and then use it for the shell.

Something simple like:
Code:
#!/bin/bash
exec mysql -u user -password
That way when the user exits mysql, he is logged out.

This comes under the topic of "captive account". "captive login", or "restricted shell", and isn't used that often any more, but the capability is still there.
 
2 members found this post helpful.
Old 03-24-2015, 06:49 PM   #6
sirDexter
LQ Newbie
 
Registered: Mar 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks, that what I wanted.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] exit in script files cause konsole terminal itself to exit Star_Gazer Programming 11 04-12-2010 09:32 AM
htop execute and exit... chamila1986 Linux - Newbie 2 01-16-2010 04:21 PM
top-execute and exit chamila1986 Linux - Newbie 3 01-07-2010 02:47 AM
Help? how to execute the /etc/profile without having the user exit then logon? icecoolcorey Programming 3 06-12-2008 10:48 AM
SSH: execute one command then exit kleptophobiac Linux - Software 10 01-30-2004 09:21 PM


All times are GMT -5. The time now is 09:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration