LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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-31-2008, 12:57 PM   #1
guardiantorj
LQ Newbie
 
Registered: Mar 2008
Posts: 9

Rep: Reputation: 0
Script Conversions


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.
 
Old 03-31-2008, 04:15 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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.
 
Old 04-01-2008, 08:35 AM   #3
guardiantorj
LQ Newbie
 
Registered: Mar 2008
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
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
 
Old 04-01-2008, 11:22 AM   #5
guardiantorj
LQ Newbie
 
Registered: Mar 2008
Posts: 9

Original Poster
Rep: Reputation: 0
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
 
Old 04-01-2008, 12:20 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
NP. Good to see you're getting there.
 
Old 04-01-2008, 01:48 PM   #7
guardiantorj
LQ Newbie
 
Registered: Mar 2008
Posts: 9

Original Poster
Rep: Reputation: 0
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
 
Old 04-01-2008, 02:08 PM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Code:
#!/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.

Last edited by unSpawn; 04-01-2008 at 02:11 PM.
 
Old 04-01-2008, 02:41 PM   #9
guardiantorj
LQ Newbie
 
Registered: Mar 2008
Posts: 9

Original Poster
Rep: Reputation: 0
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.

Thanks again
 
Old 04-01-2008, 03:07 PM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by guardiantorj View Post
I have gotten alot out of this problem on a learning basis and from a problem solving basis.
Well done. Do check out the Programming forum if shell scripting (or programming) is going to be your thing.
 
Old 04-07-2008, 03:01 PM   #11
guardiantorj
LQ Newbie
 
Registered: Mar 2008
Posts: 9

Original Poster
Rep: Reputation: 0
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.
 
  


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
Pointer Conversions KissDaFeetOfSean Programming 3 07-21-2005 02:17 AM
IDN conversions markus1982 Programming 1 03-11-2004 12:38 PM
Bulk image format conversions with a shell script? infidel Linux - Software 4 11-16-2003 07:20 PM
Need help with conversions in C green_dragon37 Programming 1 06-07-2003 01:03 AM
Graphics conversions that_girl Linux - Newbie 1 04-05-2002 07:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:55 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