LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 05-07-2010, 09:51 PM   #1
graphixfx
LQ Newbie
 
Registered: Jun 2009
Posts: 5

Rep: Reputation: 0
How can I make a script to open a program then operate within that program?


I am very new to linux and am trying out script writing.
I am using shell.
How can I make a script to open a program then operate within that program?
Thanks
 
Old 05-07-2010, 10:08 PM   #2
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
It's not very clear what you mean. If you could be more explicit, with an example, at least in concept, then we might be able to give an answer.

Also, if you start by doing some simple things, and then develop those, you will learn by doing, and you will also have more explicit questions.
 
Old 05-07-2010, 10:19 PM   #3
graphixfx
LQ Newbie
 
Registered: Jun 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Okay just for experimentation purposes I want to make a script to open firefox then perhaps go to a particular website or open VLC media player and play a specific file, stuff like this to open a program then have the program perform a task controlled by the script.....does that make more sense?
 
Old 05-07-2010, 10:21 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Code:
#!/bin/bash

command1
command2
command3
etc...
At the most basic level, a script is nothing more than a text file containing a series of commands to be run serially. It doesn't matter if the command is cli, gui, or built-in. When one command exits, the script will launch the next one on the list.

At higher levels, there's also a scripting language that allows you to run commands conditionally, or in loops, or in other programmatic ways, and of course there are exceptions and special cases, but underneath it all it's still a one-command-at-a-time process.

If you gave us some details about what you're trying to accomplish, maybe we could help you more directly.

Edit: seeing your reply above, what you probably want is a macro recorder. These are programs that record a series of actions, mouse-clicks, key punches, etc. Then you can play the whole sequence back again.

Check out cnee/gnee/xnee or jw_record/playback.

If you want something more flexible, then it depends on the specific program you want to work with. If the program is controllable through cli, then you can probably script something for it.

Last edited by David the H.; 05-07-2010 at 10:30 PM.
 
Old 05-07-2010, 11:29 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Here's an example of starting Firefox and opening three LQ pages
Code:
# Linux Questions
/usr/bin/firefox \
    'http://www.linuxquestions.org/questions/search.php?do=process&showposts=0&starteronly=1&exactname=1&searchuser=catkin' \
    'http://www.linuxquestions.org/questions/subscription.php' &
sleep 10
/usr/bin/firefox \
    'http://www.linuxquestions.org/questions/search.php?do=getnew' \
    &
Notes:
  • The "\" characters mean the command is continued on the next line.
  • The "&" characters mean "do not wait for this command to complete before executing the next one".
  • The sleep for 10 seconds is necessary because LQ doesn't accept too-frequent searches.
 
Old 05-08-2010, 08:21 AM   #6
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,377

Rep: Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108
It's worth noting ...

A script that invokes a program might or might not be able to subsequently control that program: it depends entirely upon the program in question.

If "the program in question" supports scripting on its own, however, then it's probably possible for "script #1" to start the program and to instruct that program to "run script #2 upon startup." Once again, it depends entirely upon what "the program in question" has been designed to do, what sort of scripting it supports, and so on.

Many scripting languages that are available in Linux are designed to be usable by programs, which are able to "expose interfaces" to those scripts. For example, Blender (the great open-source 3D-graphics package that I use a lot in my work these days) supports Python. You can write a script within the Blender environment, and say use Blender within that script, and "off you go."
 
  


Reply

Tags
program, script, shell


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
how to use program or script to control the mice to operate the applications?? inmy21c Linux - Desktop 2 10-16-2008 09:13 AM
how to use program or script to control the mice to operate the applications?? inmy21c Programming 2 10-16-2008 06:41 AM
Bash Script - How do I make sure my program is still running? nro Linux - Newbie 4 08-28-2005 01:57 PM
can i make a script or program make a phone call? nephish Linux - Software 2 08-15-2005 09:02 PM
i make a program using forte how can i generate from that program an rpm abdelhlims Programming 0 07-13-2004 12:10 PM


All times are GMT -5. The time now is 07:53 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration