[SOLVED] How to execute bash script upon entering a certain directory.
Linux - NewbieThis 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.
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.
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.
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?
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
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.
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.
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.
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):
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.
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.