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.
I am looking to convert a VBscript to Python or some other language that can be used in linux. It is an old script that I used in windows that when a user would log into the device it would start Firefox or IE (windows days) and then when the browser would close the device would shutdown with the closing of that application. Is there a way to convert it or would it be easier to find help writing it in a language supported by linux? Any and All help with this would be great. I have only been using linux about 3 months now so any and all help is greatly appreciated.
Converting no, but running Xorg with Firefox instead of a desktop environment and logging out when FF is closed isn't that hard to do. Adding system shutdown on FF close as well goes a bit against the grain since it's a multi-user OS but should be easy to add too. What you need is a user account without password (or use pam_usb and a USB stick), add Firefox as default DE choice in /etc/X11/ and a post-session script to have it shut down.
That is the script I am in need of help with. I have done the same thing with windows with a VB script but I am now trying to do this with Ubuntu or Fedora. I am working with Ubuntu now but have worked with Fedora in the past. If someone would give me a hand with that script that would be great.
Thanks for the links they have put me in the right direction along with some other syntax pages that are linked I think I got it figured out on what I have to do. Thanks
Ok I have found after much reading and frustration that I have been making things harder than what they need to be. I have learned that BASH is much like DOS and i like dos so I have been working with that and have came up with the script below but when FireFox is not open it doesn't shut down like the script says. Am I a bit off on the syntax, way off, or just running down the wrong path? Any thoughts?
Thanks,
SCRIPT:
if [ 'pidof firefox-bin' ]
then sleep 15
else
shutdown -f
fi
#!/bin/sh --
# Nearly OK except you don't want to *not* shutdown after sleep, so:
if [ `/sbin/pidof firefox-bin` ]; then
sleep 15s
fi
/sbin/shutdown -h now
exit 0
...and watch it. Those aren't single quotes but backticks, the equivalent of $(someCommand).
Code:
#!/bin/sh
# But you really don't need the PIDs, just the exit value, so this works too:
pgrep -f 'firefox-bin' >/dev/null 2>&1 && sleep 15s
/sbin/shutdown -h now
exit 0
...and if this is the postSession script you might as well just kill firefox right away, right? If not the system will kill anything on shutdown automagically.
Thanks for catching that and thank you for all of your help. I have gotten alot out of this problem on a learning basis and from a problem solving basis. My problem is solved.
I did use the first script but changed the line --if [ `/sbin/pidof firefox-bin` ]; then -- to -- if [ `pidof firefox-bin` ]; then -- and then it worked perfect.
I am running a script with an IF statement but I need it to wait 45seconds before it starts. But with the sleep there it works but skips my if statement for some reason and shuts down even though firefox is open. Any thoughts?
#!/bin/sh --
sleep 45s
if [ ` pidof firefox-bin` ]; then
sleep 15s
fi
sudo /sbin/shutdown - h now
exit 0
What the script is to do is look and see if firefox is running and if it is wait 15 seconds and check again. I just need 45 seconds to have fire fox get started. Then if Firefox is closed the device shuts off. I am working on creating a Internet kiosk style workstation.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.