How to start application and keep script running


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to start application and keep script running
# 1  
Old 12-17-2010
How to start application and keep script running

What I'm looking for is best explained with a little example.
Code:
#!/bin/bash
gedit
echo "I need this message to appear while gedit is still running, but it appears only then when I close gedit."

Of course most of the times you want the script to wait, but in this case I want to start a new process thread.

Probably the answer is simple, but I couldn't find it.
# 2  
Old 12-17-2010
Code:
gedit &
echo "blabla ..."

This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 12-17-2010
Quote:
Originally Posted by ctsgnb
Code:
gedit &
echo "blabla ..."

Well as I said.. it's a simple example.. actually this is in the middle of a process. And a lot of intructions follow. I can't use this trick. The script must be able to run until the end. And then exit. And continue the series of scripts that follow.

---------- Post updated at 10:39 AM ---------- Previous update was at 10:10 AM ----------

Quote:
Originally Posted by MrZehl
Well as I said.. it's a simple example.. actually this is in the middle of a process. And a lot of intructions follow. I can't use this trick. The script must be able to run until the end. And then exit. And continue the series of scripts that follow.
Hmm I thought about it and it turned out that I can use it as solution. I made a script called 'newthread' in my bin directory.
Code:
#!/bin/bash
$@ &
exit

Now the script works
Code:
#!/bin/bash
newthread gedit
echo "Yes, gedit is running now"
# rest of the code

But is would be nice if there is a solution without the use of an extra script. So the question is still a bit open.
# 4  
Old 12-17-2010
Well, you wont get much more help with your issue if you dont submit your script so we can undestand your issue, for so far and with the given information, ctsgnb suggestion is correct.
Code:
#   test0001
echo blahblah
xclock&
echo "try the following:"
ll
date
date +%u%H
echo the end

output:
Code:
zra:/home/vbe $ test0001   
blahblah
try the following:
total 804
-rwxrwxrwx   1 root       sys            101 Oct  8 15:18 0001
-rw-rw-r--   1 vbe        bin             49 Dec  2 16:29 002_param
-rw-rw-rw-   1 vbe        bin             31 Jul  8 13:17 SERVERNAMES
-rw-rw-rw-   1 vbe        sys           1892 Feb 10  2004 abenezra.top
-rw-rw-rw-   1 vbe        sys           1891 Feb 10  2004 abenezra01.top
-rw-rw-rw-   1 vbe        sys           1887 Feb 10  2004 abenezra02.top
-rw-rw-rw-   1 vbe        bin           4041 Feb 10  2004 abenezra_pb.log
-rw-rw-r--   1 vbe        bin          13077 Nov  6  2008 abenezra_pb001.log
-rw-rw-rw-   1 vbe        bin           2013 Mar 16  2004 bdf.040316
-rw-rw-rw-   1 vbe        bin           2094 Sep 29  2005 bdf.050929
-rw-r--r--   1 root       sys           2183 Apr 17  2007 bdf.070417
-rw-r--r--   1 root       sys           2012 Mar  5  2008 bdf.080305
-rw-r--r--   1 root       sys           2013 Mar 14  2008 bdf.080314
-rw-r--r--   1 root       sys           2013 Jan 11  2006 bdf060111
-rwxrwxr-x   1 vbe        bin            393 Apr  7  2008 calcul
-rw-rw-rw-   1 root       sys            869 Jan 30  2004 caph_ping.log
-rwxrwxrwx   1 vbe        bin          28672 Jun 18  2002 cob01
-rw-rw-rw-   1 vbe        bin            575 Jun 18  2002 cob01.cob
-rw-rw-rw-   1 vbe        bin           1792 Jun 18  2002 cob01.int
-rw-rw-rw-   1 vbe        bin           2656 Jun 18  2002 cob01.o
-rwxrwxrwx   1 vbe        bin            235 May 14  2004 cob_profile
drwxrwxrwx   2 vbe        bin             96 Apr  5  2001 cobol
-rw-rw-rw-   1 vbe        bin           1466 Jun 18  2002 cobol_pb.what
-rw-r--r--   1 root       sys           5522 Oct 27 14:47 code_2debug
-rw-rw-rw-   1 vbe        bin          20803 Aug 24 15:47 cpio_log.100823
-rw-rw-rw-   1 vbe        bin             62 Aug 16 16:13 dos2ux_pb.txt
-rw-rw-r--   1 root       sys            634 Oct  8 18:34 file
-rw-rw-r--   1 root       sys            360 Oct  6 18:03 file01
-rw-rw-r--   1 root       sys            443 Oct  6 18:05 file02
-rw-rw-rw-   1 vbe        bin            108 May 20  2010 firmwar_patch
-rw-rw-rw-   1 vbe        bin           1068 Apr  3  2001 flex_id
-rwxrwxr-x   1 vbe        bin            124 Jul  8 16:53 function.ksh
-r-xr--r--   1 vbe        bin          24576 Feb  1  2008 fuser
-rw-rw-rw-   1 vbe        bin          48334 Jun  8  2010 gaga_test01.txt
-rw-r--r--   1 vbe        bin              5 May 22  2001 gc.toto
-rwxr-xr-x   1 root       sys           1592 Mar 16  2006 getsysinfo
-rw-r--r--   1 root       sys           3911 May 20  2010 ioscan_100520.out
-rw-r--r--   1 root       sys           2519 Jan  7  2010 java1.3_install.log
-rw-rw-rw-   1 vbe        bin            720 Apr  5  2001 lic.se_mf
-rw-rw-r--   1 vbe        bin            809 Aug 25 10:56 list001.txt
-rw-rw-r--   1 root       sys              3 Oct  5 14:03 log.size
drwxrwxr-x   3 root       sys             96 Oct  5 14:06 logs
-rw-rw-rw-   1 vbe        bin           1915 Jun 15  2010 lp_print.txt
-rw-rw-rw-   1 vbe        bin            207 Jul  8 17:12 mairan_dsk.eval
-rw-r--r--   1 root       sys          31882 Jun 24 17:23 manips.100624
-rw-r--r--   1 root       sys            122 Aug 30 10:51 mapfile
-r--r--r--   1 vbe        bin           4021 Apr  5  2001 mfcobolrc
-rw-r--r--   1 root       sys           1980 Jun 24 15:41 mflic_adm_s.out
-rwxrwxr-x   1 root       sys           1764 Sep  8 15:41 mt_pt_contents_get
drwxrwxr-x   2 vbe        bin             96 Nov  8 10:01 n20
-rwxr-xr-x   1 root       sys            305 Dec  1  2009 nddget_check
-rw-r--r--   1 root       sys            340 Dec  1  2009 nddsetbastil
-rw-r--r--   1 root       sys            541 Mar 14  2008 nfs_mount.which
-rw-------   1 root       sys              0 Jun 21 14:50 nohup.out
drwx------   2 vbe        bin             96 Mar 29  2004 nsmail
-rw-rw-r--   1 vbe        bin           5082 Aug 30 10:26 octant_r_dskmanip.log
-rw-r--r--   1 root       sys            122 Aug 30 10:47 octant_vg03.map
-r--------   1 root       sys             16 Aug 30 10:47 octant_vg03.pvmap
-rw-rw-rw-   1 vbe        bin              0 Oct 27  2009 output.txt
-rw-rw-rw-   1 root       sys            485 Feb 11  2004 patrol.pb
-rw-rw-rw-   1 vbe        bin           6095 Nov 28  2001 pty.log
-rw-rw-rw-   1 vbe        bin             74 Apr  4  2001 put_merantcobol
-rw-rw-rw-   1 vbe        bin             98 Apr  4  2001 remove_hpcobol
-rw-r--r--   1 root       sys          48334 May 27  2010 restore_err.txt
-rw-rw-rw-   1 vbe        bin           1804 Jun 15  2010 root_dsk_changed.10015
-rw-r--r--   1 root       sys            406 Nov 21  2007 shell_current_pbtoknow
-rw-rw-r--   1 root       sys           1075 Oct  8 12:56 sort_file
-rw-rw-rw-   1 vbe        bin            729 May 12  2005 start_tipix.howto
-rwxr--r--   1 vbe        bin             15 May 22  2001 test.ksh
-rwxr-x---   1 vbe        bin             80 Dec 17 10:43 test0001
-rwxrwxr-x   1 vbe        bin            145 Aug 18 15:49 test_date_awk
-rwxrwxr-x   1 root       sys            963 Oct  5 14:32 testing.script
-rwxrwxrwx   1 root       sys            412 Aug 24 15:57 testing_dsk_perf
-rw-r--r--   1 vbe        bin           8713 Apr  3  2001 tictac.cbl
-rw-rw-rw-   1 vbe        bin          50688 Apr  5  2001 tictac.idy
-rw-rw-rw-   1 vbe        bin           3584 Apr  5  2001 tictac.int
-rw-r--r--   1 root       sys            188 Nov 17 14:29 time_span.pb
-rw-r--r--   1 root       sys           3551 May 23  2005 tipstart.howto
-rw-r--r--   1 root       sys            435 Aug 16 15:35 titi.txt
-rw-rw-r--   1 vbe        bin            517 Aug 27 16:25 titi000.txt
-rw-r--r--   1 root       sys            435 Aug 16 15:53 titi_01.txt
-rw-r--r--   1 root       sys            435 Aug 16 16:06 titi_02.txt
-rw-rw-r--   1 vbe        bin             42 Nov  4 16:08 tt01
-rw-rw-r--   1 vbe        bin             35 Nov  4 16:06 tt02
-rw-rw-r--   1 vbe        bin             77 Nov  4 16:11 tt03
-rw-rw-rw-   1 vbe        bin           2827 Jul  2 16:54 typescript
-rwxr-x--x   1 vbe        bin            112 Dec  7 16:10 use_bc
-rw-r--r--   1 root       sys            426 Aug 30 10:50 vg_groupsfiles.100830
-rw-rw-r--   1 root       sys             10 Oct  7 10:03 wrapper.log.10.07.10-10:03:01
Fri Dec 17 10:48:17 MET 2010
510
the end
zra:/home/vbe $


Last edited by Scott; 12-17-2010 at 05:55 AM..
This User Gave Thanks to vbe For This Post:
# 5  
Old 12-17-2010
Quote:
Originally Posted by vbe
Well, you wont get much more help with your issue if you dont submit your script so we can undestand your issue, for so far and with the given information, ctsgnb suggestion is correct.
Oh, I'm sorry. Indeed, actually it works very well. I thought I knew about '&" and thought it only executed the first following command. So I didn't test it. But it seems I was terribly mistaken. I'm sorry for the confusion. And I promise next time I will thoroughly test any suggestion before making comments.

Thanks to you both for the solution.
# 6  
Old 12-17-2010
You welcome
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

The application was unable to start correctly(0xc0150002).

Dear Team, please help me on the issue "The application was unable to start correctly(0xc0150002).click ok to close the application" Have created the build using installshield 2012. dll was generated from VS2008. Used 3rd party libraries.Included all the libraries,dll. This was the first tme... (1 Reply)
Discussion started by: SA_Palani
1 Replies

2. Shell Programming and Scripting

Want to backup dirs on application start and close.

Hi I want to write a script that will back up one directory if a certain application launches and then backs up another directory if that same application is closed down. NFI where to start. It seems like cron isn't the tool for this because that is time based. I'm thinking I need... (6 Replies)
Discussion started by: zorrokan
6 Replies

3. Shell Programming and Scripting

AWK - Issues with script running at start of month.

I have a script that runs on an AIX 5.3.10.0. It runs perfectly on days that are double digit numbers, but from the 1st to the 9th of the month it runs but does not report anything. The command in the script is as follows: awk -v d=$(date '+%b%d') '/user:warn/ && /has shutdown/ && ($1$2 ==... (2 Replies)
Discussion started by: jimbojames
2 Replies

4. UNIX for Advanced & Expert Users

script to remotely start an application instance

just wanted to ask if anybody have script template for the subject above so I can make ti as my guide? example a. server 1.1.1.1: restart script located at /etc/init.d/glassfish.sh b. server 2.2.2.2: central script that support admin will use to execute to restart the /etc/init.d/glassfish.sh... (0 Replies)
Discussion started by: lhareigh890
0 Replies

5. Shell Programming and Scripting

How can I start a SH application when someone makes a ssh connection?

Hello everyone, I'm trying to control the access in my server. I did an application that can read audit logs and sys logs with the purpose to send me a report by email with important information about the user. It's a SH file. My problem is start the program when someone makes a ssh connection.... (4 Replies)
Discussion started by: journey
4 Replies

6. Shell Programming and Scripting

Start and stop of an application thru shell scripts.

Hi, I just learnt the shell scripting and got working on that right now. I have one problem. Here i am having a java application that needs to be start and stop using two shell scripts, i.e., starting the java application using one shell script and stopping the application using another... (1 Reply)
Discussion started by: sadha
1 Replies

7. Linux

where to put an application if i want to start it on start up

hi i want to know the way by which i put any file somewhere and it get s started when the system restarts or bots i mean whenever my system starts that application must also start thanks (3 Replies)
Discussion started by: shukla_chanchal
3 Replies

8. UNIX for Dummies Questions & Answers

Script to Test Application Server is running

Hi, I'm a complete novice at Unix and need to create a script that does the following... checks to see if an application server is running. If the app is running then print 'Available' Else print 'Unavaliable' exit from scriopt I have no idea where to start. I'd be very grateful... (0 Replies)
Discussion started by: duglover
0 Replies

9. UNIX for Dummies Questions & Answers

how do i auto start application upon startup?

sorry, i'm a newbie to unix... but how do i or rather where do i write scripts that auto start my application e.g. Informix? in Windows it would be services but in UNIX where can i auto start my informix program? To run informix i just type "oninit". And do i have to login to any user before... (2 Replies)
Discussion started by: doofie
2 Replies

10. UNIX for Advanced & Expert Users

Start application after Oracle has started

Who can tell me how I can see to it that a application doesn't try to start it's processes untill Oracle has completely started. Thanx. (3 Replies)
Discussion started by: Piet
3 Replies
Login or Register to Ask a Question