Author Topic: Start A Network Connection From The Command Line  (Read 39108 times)

BarrySamuels

  • Full Member
  • ***
  • Posts: 103
    • View Profile
    • http://www.beenthere-donethat.org.uk
Start A Network Connection From The Command Line
« on: October 26, 2006, 10:43:19 am »
C3100 with standard Sharp ROM

Can someone give me the required commands to start a specific wireless network connection from the command line please? I want to set up a script to do it.
« Last Edit: October 26, 2006, 10:44:47 am by BarrySamuels »
Barry Samuels
http://www.beenthere-donethat.org.uk
The Unofficial Guide to Great Britain

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
Start A Network Connection From The Command Line
« Reply #1 on: October 26, 2006, 12:01:35 pm »
I don't know if it is possible to start a specific network connection, but you can raise the network conection selector dialog from the command line using:

qcop "QPE/Network" "connectRequest()"

A script for establishing a network connection and chacking for availability of Internet could look that way (I have used that a lot for mutt etc.):

Code: [Select]
#! /bin/bash

TRY_IP="130.149.4.20"

echo Connecting to Internet...
qcop "QPE/Network" "connectRequest()" > /dev/null 2>&1


ping -c 1 "$TRY_IP"  > /dev/null 2>&1
while [ $? -ne 0 ]
do
  sleep 5
  echo waiting for network...
  ping -c 1 "$TRY_IP" > /dev/null 2>&1
done
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

BarrySamuels

  • Full Member
  • ***
  • Posts: 103
    • View Profile
    • http://www.beenthere-donethat.org.uk
Start A Network Connection From The Command Line
« Reply #2 on: October 27, 2006, 09:07:13 am »
Quote
I don't know if it is possible to start a specific network connection, but you can raise the network conection selector dialog from the command line using:

qcop "QPE/Network" "connectRequest()"
[div align=\"right\"][a href=\"index.php?act=findpost&pid=144886\"][{POST_SNAPBACK}][/a][/div]
Thanks Daniel that gave me an idea and I did a search on 'qcop'.

I found some more qcop functions:

QPE/Network:
  connectRequest()
  disconnectRequest(int)

QPE/System:
  __network_connect
  __network_disconnect

I tried the System functions thus:

qcop "QPE/Network" "__network_connect" but that gave me a syntax error so I tried qcop "QPE/Network" "__network_connect()" which got rid of the error but didn't appear to do anything.

The QPE/System functions look interesting but don't appear to have any effect. Has anyone tried to use them?
Barry Samuels
http://www.beenthere-donethat.org.uk
The Unofficial Guide to Great Britain

bam

  • Hero Member
  • *****
  • Posts: 1213
    • View Profile
    • http://thegrinder.ws
Start A Network Connection From The Command Line
« Reply #3 on: October 28, 2006, 01:53:29 am »
try
qcop QPE/Network connectRequest()

brings up the network applet connection select screen.
SL-C3100 current: Stock/Tetsu 18h
Socket BT CF Card
Linksys WCF-12 802.11b/Cheapie USB Ethernet

The Grinder

speculatrix

  • Administrator
  • Hero Member
  • *****
  • Posts: 3708
    • View Profile
Start A Network Connection From The Command Line
« Reply #4 on: November 16, 2006, 11:40:11 am »
this has worked for me, from memory...

cardctl scheme qpewlan0
cardctl reset
Gemini 4G/Wi-Fi owner, formerly zaurus C3100 and 860 owner; also owner of an HTC Doubleshot, a Zaurus-like phone.

cvmiller

  • Full Member
  • ***
  • Posts: 242
    • View Profile
    • http://
Start A Network Connection From The Command Line
« Reply #5 on: November 20, 2006, 09:26:00 pm »
Quote
try
qcop QPE/Network connectRequest()

brings up the network applet connection select screen.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=144997\"][{POST_SNAPBACK}][/a][/div]

These commands look quite interesting. but they don't do a thing for me on my Zaurus ROM. No matter what I type (a valid command, that is) I get the error:
bash-2.05$ qcop QPE/Network 'connectRequest()'
SlSharedManager: can't get proc entry
Display size = 480x640

Is there something else that needs to be loaded before issuing qcop commands?

TIA,

Craig...
SL-6000
ROM v1.12 (Sharp)
Belkin F8U1500 IR Keyboard
1 GB SD Card by SanDisk (ext2)

speculatrix

  • Administrator
  • Hero Member
  • *****
  • Posts: 3708
    • View Profile
Start A Network Connection From The Command Line
« Reply #6 on: December 05, 2006, 07:28:20 pm »
Quote
this has worked for me, from memory...

cardctl scheme qpewlan0
cardctl reset
[div align=\"right\"][a href=\"index.php?act=findpost&pid=146455\"][{POST_SNAPBACK}][/a][/div]

to shutdown the network connection, use "cardctl scheme Suspend"

the problem with this is that it bypasses qtopia and so the network connection applet doesn't indicate connected or not.
Gemini 4G/Wi-Fi owner, formerly zaurus C3100 and 860 owner; also owner of an HTC Doubleshot, a Zaurus-like phone.

freizugheit

  • Sr. Member
  • ****
  • Posts: 409
    • View Profile
    • http://
Start A Network Connection From The Command Line
« Reply #7 on: December 05, 2006, 08:54:42 pm »
Quote
to shutdown the network connection, use "cardctl scheme Suspend"

the problem with this is that it bypasses qtopia and so the network connection applet doesn't indicate connected or not.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=148197\"][{POST_SNAPBACK}][/a][/div]


Use ifconfig to check whether the network connection is up or down.

speculatrix

  • Administrator
  • Hero Member
  • *****
  • Posts: 3708
    • View Profile
Start A Network Connection From The Command Line
« Reply #8 on: December 06, 2006, 07:40:42 am »
Quote
Quote
to shutdown the network connection, use "cardctl scheme Suspend"

the problem with this is that it bypasses qtopia and so the network connection applet doesn't indicate connected or not.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=148197\"][{POST_SNAPBACK}][/a][/div]


Use ifconfig to check whether the network connection is up or down.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=148202\"][{POST_SNAPBACK}][/a][/div]

tee hee  , I know that, I'm just pointing out that if you use cardctl to directly switch on wireless, you can't then use the GUI to turn it off!
Gemini 4G/Wi-Fi owner, formerly zaurus C3100 and 860 owner; also owner of an HTC Doubleshot, a Zaurus-like phone.

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Start A Network Connection From The Command Line
« Reply #9 on: March 11, 2007, 10:51:43 am »
To start my dialup connection from the command line, and have qtopia know it is there, I enter:

qcop QPE/Network  'start(QString,QString)' "/home/root/Applications/Network/modules/DialUp30.conf" ""

You would substitute in the pathname of your particular network configuration file.  Our roms are different, but I always use the "Internet Wizard" GUI to set up my configuration file.

It should work the same no matter what type of network connection you have.  My applet always shows the correct status when I start from commandline.
sdjf
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards

BarrySamuels

  • Full Member
  • ***
  • Posts: 103
    • View Profile
    • http://www.beenthere-donethat.org.uk
Start A Network Connection From The Command Line
« Reply #10 on: March 12, 2007, 08:32:01 am »
This is to notify the world in general that sdjf is a splendid chap!

His suggestion does, indeed, work and Qtopia seems aware of that!  

Just what I need - thanks sdjf.

(Everything comes to him who waits)
« Last Edit: March 12, 2007, 08:32:58 am by BarrySamuels »
Barry Samuels
http://www.beenthere-donethat.org.uk
The Unofficial Guide to Great Britain

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Start A Network Connection From The Command Line
« Reply #11 on: March 12, 2007, 08:47:49 am »
Quote
This is to notify the world in general that sdjf is a splendid chap!

His suggestion does, indeed, work and Qtopia seems aware of that!   

Just what I need - thanks sdjf.

(Everything comes to him who waits)
[div align=\"right\"][a href=\"index.php?act=findpost&pid=156005\"][{POST_SNAPBACK}][/a][/div]

Thanks for the compliment (sdjf shuffles feet a little).

I am very sorry I didn't run across your post sooner, and very happy the command worked for you.

sdjf
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Start A Network Connection From The Command Line
« Reply #12 on: March 22, 2007, 06:51:11 pm »
Barry,

Do you mind my asking why you wanted to do it in a script?  Most people prefer GUIs, although I also am starting my dialup connections from the command line so I have more control over what's going on, although I've been using opie-sh to make my selection of which connection.

sdjf
« Last Edit: March 22, 2007, 06:53:12 pm by sdjf »
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards

BarrySamuels

  • Full Member
  • ***
  • Posts: 103
    • View Profile
    • http://www.beenthere-donethat.org.uk
Start A Network Connection From The Command Line
« Reply #13 on: March 24, 2007, 05:51:01 pm »
Quote
Barry,

Do you mind my asking why you wanted to do it in a script?  Most people prefer GUIs, although I also am starting my dialup connections from the command line so I have more control over what's going on, although I've been using opie-sh to make my selection of which connection.

sdjf
[div align=\"right\"][a href=\"index.php?act=findpost&pid=157011\"][{POST_SNAPBACK}][/a][/div]

Ah! Now that's a long story.

It all started with the GUI for kismet. I couldn't get it to work for me so I set up a script to do it for me. I renamed the original kismet_qt script, called my new script kismet_qt. so that it would then start when I clicked the kismet icon. My new script starts Kismet Server first then calls the renamed kismet_qt.

That worked for me but as I don't use it frequently I often forgot to start the network connection first. I've now included an extra bit in my script which starts the network connection, waits until it's up and running then proceeds to start the kismet stuff all from clicking an icon. Just the sort of thing someone of my age (70) with a bad memory needs.

Thoroughly confused? Well you did ask.  
Barry Samuels
http://www.beenthere-donethat.org.uk
The Unofficial Guide to Great Britain

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Start A Network Connection From The Command Line
« Reply #14 on: March 25, 2007, 03:50:37 am »
Don't want to disappoint you, but I'm not confused at all.

This is linux, after all, and that gives us the ability to write scripts to make things easier for us.  I think that was a great idea.

What command did you use to determine if the connection was up?  I've used route or ifconfig, but also sometimes use grep to check my log and make sure authentication has been completed.

sdjf
« Last Edit: March 25, 2007, 03:51:57 am by sdjf »
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards