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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
11-25-2016, 12:46 AM
|
#1
|
LQ Newbie
Registered: Nov 2016
Posts: 5
Rep:
|
How to execute bash script upon entering a certain directory.
I have a bash script that displays a pop-up to the user and I would like the script to run when a user opens a certain directory. They would enter it via GUI by the way.
|
|
|
11-25-2016, 12:49 AM
|
#2
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,781
|
looks like you need to modify the application they use. But what will happen with other apps and/or command line usage?
By the way what os/display manager/gui/app is it?
|
|
|
11-25-2016, 01:36 AM
|
#3
|
LQ Newbie
Registered: Nov 2016
Posts: 5
Original Poster
Rep:
|
I just have my own virtual ftp server on ubuntu I made because I haven't made one before, so I just wanted to learn Then I learned how to make a bash script for printing stuff in a welcome message etc. Then I made a script that display a pop-up using zenity, it also saves the user input in a variable and then some other stuff happens. I just want to know if there is a way to have the script execute upon entering a that certain directory or if there is some other way this could be done :s
|
|
|
11-25-2016, 01:39 AM
|
#4
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,253
|
Have a look at inotify-tools
|
|
|
11-25-2016, 07:35 AM
|
#5
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552
|
Create the script and change its icon to a generic directory one?
|
|
|
11-25-2016, 09:04 AM
|
#6
|
Moderator
Registered: Aug 2002
Posts: 26,201
|
You did not provide any information on the GUI but I assume it is a regular ftp client. Assuming that the GUI would read the contents of the directory then inotify would detect that event and therefore run a script. However, the script will not run within the GUI and is a separate process. As suggested you would need to modify both the server and client. I do not know an easy way this could be accomplished.
|
|
|
11-25-2016, 09:55 AM
|
#7
|
LQ Newbie
Registered: Nov 2016
Posts: 5
Original Poster
Rep:
|
Quote:
Originally Posted by keefaz
Create the script and change its icon to a generic directory one?
|
Yeah but I want the person to get into an actual directory, i just want my script to execute when he goes into it, if i make the script look like a folder, even if it executes he still won't get into the folder now will he, i could add a 'enter the folder' line at the end of the script, but that would only affect terminal, it wouldn't actually take him inside the file.
|
|
|
11-25-2016, 10:54 AM
|
#8
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,895
|
Member Response
Quote:
Originally Posted by froziii
Yeah but I want the person to get into an actual directory, i just want my script to execute when he goes into it, if i make the script look like a folder, even if it executes he still won't get into the folder now will he, i could add a 'enter the folder' line at the end of the script, but that would only affect terminal, it wouldn't actually take him inside the file.
|
I do not believe you can perform this functionality normally under Windows, MAC, or Linux. I suspect that you'd have to modify the UI File Manager which the operator is using.
|
|
|
11-25-2016, 10:58 AM
|
#9
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552
|
Quote:
Originally Posted by froziii
Yeah but I want the person to get into an actual directory, i just want my script to execute when he goes into it, if i make the script look like a folder, even if it executes he still won't get into the folder now will he, i could add a 'enter the folder' line at the end of the script, but that would only affect terminal, it wouldn't actually take him inside the file.
|
You could open a new file browser window within the script at last line (ex with thunar):
Code:
exec thunar /path/to/real/directory
|
|
|
11-25-2016, 12:35 PM
|
#10
|
Moderator
Registered: Aug 2002
Posts: 26,201
|
What is gui application?
|
|
|
11-25-2016, 12:55 PM
|
#11
|
LQ Newbie
Registered: Nov 2016
Posts: 5
Original Poster
Rep:
|
Quote:
Originally Posted by michaelk
What is gui application?
|
Just normal Ubuntu GUI, you know Sorry if I'm not using the correct term here :s
|
|
|
11-25-2016, 01:08 PM
|
#12
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,781
|
no I'm sorry but that does not exist (or all of them are normal). So it does not really help us to go forward. You may say the default one, that is probably unity, but it is still a graphical desktop, not an application.
If you don't know the name try to explain how did you start it, how did you use it at all.
|
|
|
11-25-2016, 01:29 PM
|
#13
|
LQ Guru
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,930
|
Many FTP servers have the option to look for a file with a specific name in the directory and display that file. It do not remember any that have a setting to EXECUTE a file, but you should be checking the man pages for your SERVER application (vsftp?) for detail on what it can do under these circumstances.
|
|
|
11-26-2016, 07:56 AM
|
#14
|
Moderator
Registered: Aug 2002
Posts: 26,201
|
Executing an arbitrary script on a server from a FTP client would be a huge security risk. That is not going to happen. If the OP is using a file browser then with inotify you could trigger the script. It is unclear what the OP is actually trying to accomplish.
|
|
|
11-26-2016, 10:18 AM
|
#15
|
LQ Newbie
Registered: Nov 2016
Posts: 5
Original Poster
Rep:
|
Quote:
Originally Posted by michaelk
Executing an arbitrary script on a server from a FTP client would be a huge security risk. That is not going to happen. If the OP is using a file browser then with inotify you could trigger the script. It is unclear what the OP is actually trying to accomplish.
|
I'm just doing this to learn, security doesn't matter in this case. And by the GUI, if you were to go to ubuntus site and download the newest desktop version of ubuntu, install it and boot it, that is the GUI I am talking about, the 'default one', the default graphical desktop :s
|
|
|
All times are GMT -5. The time now is 04:45 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|