LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training 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-31-2008, 01: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, 05:15 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
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, 09: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, 12:22 PM   #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, 01:20 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
NP. Good to see you're getting there.
 
Old 04-01-2008, 02: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, 03:08 PM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
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 03:11 PM.
 
Old 04-01-2008, 03: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, 04:07 PM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
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, 04: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


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

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

All times are GMT -5. The time now is 05:06 AM.

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