WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to delay the launch of an application?  (Read 3545 times)

Offline elrick

  • Newbie
  • *
  • Posts: 13
How to delay the launch of an application?
« on: August 30, 2013, 11:00:58 AM »
Hi guys,
I need your help. I'am trying to set up Putty, to load session on startup in Core Plus. I've wrote short script:
Code: [Select]
putty -load SessionNameI've saved file as putty.sh and I placed it in .X.d folder, its working, but it fails to load session, I think its because network is not ready, so how can I delay startup of putty?

I tried:

Code: [Select]
putty -load SessionName | wait:20s
Code: [Select]
putty -load SessionName -wait:20s
Code: [Select]
putty -load SessionName -wait 20
Code: [Select]
putty -load SessionName -sleep:20s
and few other configurations, nothing works, what am i doing wrong?

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11502
Re: How to delay the launch of an application?
« Reply #1 on: August 30, 2013, 12:21:30 PM »
Hi elrick
Quote
I think its because network is not ready, ...
See this thread:
http://forum.tinycorelinux.net/index.php/topic,15806.msg92705.html#msg92705

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1026
Re: How to delay the launch of an application?
« Reply #2 on: August 31, 2013, 04:19:37 AM »
hi elrick,

perhaps you were looking for the sleep command?

#!/bin/sh

sleep 10
putty -load SessionName

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11502
Re: How to delay the launch of an application?
« Reply #3 on: August 31, 2013, 11:44:47 AM »
Hi netnomad
If his problem is waiting for the network card to be ready, the solution posted by gerald_clark in the thread I linked to
is more robust.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: How to delay the launch of an application?
« Reply #4 on: August 31, 2013, 11:47:16 AM »
Yes, a fix dealay is a bad practice, just a final solution. Much better to wait for the network is up with timeout.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1026
Re: How to delay the launch of an application?
« Reply #5 on: September 01, 2013, 05:47:14 AM »
there is no doubt ;-)

Offline elrick

  • Newbie
  • *
  • Posts: 13
Re: How to delay the launch of an application?
« Reply #6 on: September 02, 2013, 05:07:35 AM »
Thanks guys, I will try this later on and let you know if its works.

Offline elrick

  • Newbie
  • *
  • Posts: 13
Re: How to delay the launch of an application?
« Reply #7 on: September 03, 2013, 04:43:08 AM »
ok its working but not always, I have two separate networks, maybe that's causing problems, when my PC is connected to the hub and to the one of networks, script is working, and when it's boot I can see IP address for a second, when my PC is connected to the other network, when it boot I see quick message "sending discover" or "waiting for IP 60", after this putty fails to load session, and its taking about 30-60 seconds network to start working.

Here my bootlocal.sh script:

Code: [Select]
#!/bin/sh
~ put other system startup commands here
/opt/eth0.sh &
SEC=60
while [ $SEC -gt 0 ] ; do
   ifconfig | grep -q "Bcast" && break || sleep 1
   echo -ne "Waiting for IP $((SEC--))  \r"     
done                                       
echo

and putty.sh in .X.d folder

Code: [Select]
#!/bin/sh
putty -load SessionName