You are not logged in.

#1 2008-05-10 10:22:46

vbtricks
Member
From: Germany
Registered: 2008-03-20
Posts: 37
Website

[solved] Running a command in background (bash script)

Salut,

as netcfg2 does not work with my wireless connection, I have to set up the connection manually. For not having to type in the commands every time, I created a bash script.

#!/bin/bash
iwconfig wlan0 mode managed essid mynetwork channel 6
ifconfig wlan0 up
wpa_supplicant -D wext -i wlan0 -c /etc/wpa_supplicant.conf -dddd &
dhcpd wlan0

This works fine till the wpa_supplicant line. wpa_supplicant is not started in the background (as I thought, the ampersand at the end of the line would.

So how can I get wpa_supplicant run in the background?


Thanks in advance,

Stefan

Last edited by vbtricks (2008-05-11 09:13:36)

Offline

#2 2008-05-10 12:52:04

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: [solved] Running a command in background (bash script)

How do you know it isn't? What exactly does happen?

Offline

#3 2008-05-10 13:18:41

bender02
Member
From: UK
Registered: 2007-02-04
Posts: 1,328

Re: [solved] Running a command in background (bash script)

On thing is that even if it starts, it does take it a couple of seconds to connect, so it's probably not very good to run dhcpcd right after wpa_supplicant. Another thing is that you probably have a typo up there, shouldn't it be 'dhcpcd' instead of 'dhcpd'?

Offline

#4 2008-05-10 14:19:03

vbtricks
Member
From: Germany
Registered: 2008-03-20
Posts: 37
Website

Re: [solved] Running a command in background (bash script)

Ramses de Norre wrote:

How do you know it isn't? What exactly does happen?

The script does not return to the user-prompt. Is an ampersand at the end of the line the correct solution, or are you unsure yourself?

bender02 wrote:

On thing is that even if it starts, it does take it a couple of seconds to connect, so it's probably not very good to run dhcpcd right after wpa_supplicant. Another thing is that you probably have a typo up there, shouldn't it be 'dhcpcd' instead of 'dhcpd'?

Well, as the wpa_supplication command is not really run in the background the script did never execute the dhcpcd command. After having solved the above, correcting the spell-mistake will be a smaller problem. Even calling the dhcpcd command myself would be no unworkable way, the open root-shell (as I have to use another as the one calling the script is blocked) is a far greater problem...

Offline

#5 2008-05-10 14:48:58

nDray
Member
From: Portugal
Registered: 2007-01-21
Posts: 143
Website

Re: [solved] Running a command in background (bash script)

wpa_supplicant goes to the background by using the switch "-B".
man wpa_supplicant

Offline

#6 2008-05-11 09:13:25

vbtricks
Member
From: Germany
Registered: 2008-03-20
Posts: 37
Website

Re: [solved] Running a command in background (bash script)

Salut,

"-B" works fine.


Thanks,

Stefan

Offline

Board footer

Powered by FluxBB