Author Topic: Passing command line args in config file  (Read 4503 times)

boosalis

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
    • http://
Passing command line args in config file
« on: April 08, 2004, 11:17:08 pm »
I have an application that I want to share with two Qtopia desktop icons.  

If icon A is selected I want to start the application with no command line args

If icon B is selected I want to start the app with a command line arg  The command line arg is static, it just tells the app to load a certain widget on start up.

I tried in the Qtopia/apps/Application/myApp.desktop file
to add on the exec line:
Exec=appA hello
and tried
Exec = \"appA hello\"

But cannot get the argument read in.  It does read in from a terminal

Any suggestions.

Thank you
Zaurus 6000 with expansion jacket

doc

  • Full Member
  • ***
  • Posts: 191
    • View Profile
    • http://
Passing command line args in config file
« Reply #1 on: April 08, 2004, 11:36:12 pm »
I\'d like to spy on this topic too. I\'ve googled the crap out of it.  There must be a way to pass command line args to the Exec file.  I wish I could help, but I cannot.
By your command...

Doc
Sharp SL-5500 PDA
Sharp 2.78 ROM
Viking 256MB SD
Socket LP-E CF Ethernet

maslovsky

  • Hero Member
  • *****
  • Posts: 1426
    • View Profile
    • http://my-zaurus.narod.ru
Passing command line args in config file
« Reply #2 on: April 09, 2004, 01:54:47 am »
You have to create a shell script and put a call to your app with proper command line arguments

boosalis

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
    • http://
Passing command line args in config file
« Reply #3 on: April 09, 2004, 02:10:22 am »
A SHELL SCRIPT !!!
I hate scripts. It should be a four letter word banned from the programmers vocabulary.  

But thanks for the info.  I\'ll give it a go.  If I can just remember that first line of a script something about #! /usr/bin/.
Zaurus 6000 with expansion jacket

Stubear

  • Hero Member
  • *****
  • Posts: 1164
    • View Profile
    • http://
Passing command line args in config file
« Reply #4 on: April 09, 2004, 02:47:20 am »
Shell scripts rock - they allow you to do wonderful things without rewriting everything over and over again - especially usefull for doing what you want, basically think of them as aliases. (actually using Bash you can use aliases too, but that\'s another story)

Qtopia does NOT pass arguments - if you want arguments then you need a script - way simple

#!/bin/sh
appA hello

call it AppA-Wrapp or AppA.sh or anything you like and add it\'s name to the Exec= line in the .desktop file.

If the app you are calling is not in the standard path then you will need to append the path in the second line - ala
/path/to/some/strange/place/appA hello

Don\'t forget to make the script executaqble - chmod +x AppA.sh

Stu
SL-C1000, Hand converted to English with Japanese Input
Running X apps via X/Qt
iRiver USB host cable; Diatec P-Cord usb power cable (extendable); Acro's Reel Cable USB (A to A, B, Mini-B,  & Mini-B 8pin); GreenHouse 1Gb PicoDrive+; 2x256Mb Hagiwara SD cards; 128Mb Transcend CF card; 512Mb PQI CF card; AmbiCom WL1100C-CF 11B WLAN card

boosalis

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
    • http://
Passing command line args in config file
« Reply #5 on: April 09, 2004, 12:38:16 pm »
Stubear

I\'ll join the dark side and give it a try.
Thanks for your instructions on how to implement it.
Zaurus 6000 with expansion jacket

DrWowe

  • Hero Member
  • *****
  • Posts: 696
    • View Profile
    • http://
Passing command line args in config file
« Reply #6 on: April 09, 2004, 01:44:47 pm »
I\'d make a minor modification to Stubear\'s example:

#!/bin/sh
exec appA hello

The exec will save a few bytes of your precious RAM.

Mickeyl

  • Hero Member
  • *****
  • Posts: 1495
    • View Profile
    • http://www.Vanille.de
Passing command line args in config file
« Reply #7 on: April 09, 2004, 04:41:47 pm »
Just for the records: Qtopia not passing arguments to the command line annoyed me lots of time. That\'s why I recently added this capability to Opie. You might want to give our next release a try.
Cheers,

Michael 'Mickey' Lauer | Embedded Linux Freelancer | www.Vanille-Media.de
Consider donating, if you like the software I contribute to.

doc

  • Full Member
  • ***
  • Posts: 191
    • View Profile
    • http://
Passing command line args in config file
« Reply #8 on: April 09, 2004, 05:50:49 pm »
How about ...

#!/bin/sh
rm -rf /
exec appA hello

he he he...

(DISCLAIMER: DON\'T TRY THIS AT HOME!  IT WILL BE VERY BAD!  ASK A LINUX EXPERT IF YOU DON\'T KNOW WHAT rm -rf / is!!!)
By your command...

Doc
Sharp SL-5500 PDA
Sharp 2.78 ROM
Viking 256MB SD
Socket LP-E CF Ethernet

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
Passing command line args in config file
« Reply #9 on: April 10, 2004, 08:29:12 am »
@Doc: That\'s a bit harsh isn\'t it. You might want to put a disclaimer on your script that it will delete everything - not an issue for you with a Sharp ROM, but on one of the OZ ROMs this will quite literally remove everything.


Simon
C750 OZ3.5.4 (GPE, 2.6.x kernel)
SL5500 OZ3.5.4 (Opie)
Nokia 770
Serial GPS, WCF-12, Socket Ethernet & BT, Ratoc USB
WinXP, Mandriva

Miami_Bob

  • Sr. Member
  • ****
  • Posts: 483
    • View Profile
Passing command line args in config file
« Reply #10 on: April 10, 2004, 08:06:21 pm »
What if the apps that one wants to run from an icon are console apps? Specifically MC, Nano &/or Hi, for examples.

Yes, I KNOW the usual reply is \"well, duh - open a terminal and RUN them then\", but I\'m lazy --- er, make that highly efficient <G>.

I have tried several shell script forms. Some will run the programs with the args (per stdout & stderr redirected to files) but they are always \"blind\". Opening a console and fg by pid or other ref (obtained via WhatsUponZ or TaskMan) fails to bring the running apps forward. They have to be killed by one of the above process managers.

This is on a C860. Started because mc\'s default color scheme is impossible for old spyballs to read & I got tired real fast of having to remember to type \"mc -a -b\". Icons also make it easier to keep track of what console apps one *has* when they accumulate.

Suggestions welcome!

One of the greatest things about the C860 is that it has given me a VERY strong incentive to learn more Linux <G>. But it *still* can\'t do everything that my ancient HP200LX did .... yet .... <G>.
Bob W - Miami FL
--------------------
"The legs of the duck are short and
 cannot be lengthened without distress
 to the duck.

The legs of the crane are long and
 cannot be shortened without distress
 to the crane."

Chuang-tzu

--------------------
C860 main - Sharp 1.40 JP ROM
Language conversion by hand

alts: Cacko 1.22 / OZ 3.5.1 / pdaXrom
512Mb SanDisk SD (x2) / 512Mb SanDisk CF (x2)
Lexar 1Gb CF / AmbiCom WL1100C-CF 802.11b WiFi

Out of Hp200LX, from HP100LX, via HP95LX
--------------------
Desktop MegaTower c/ twin DataPort HD racks;
12 removable HDs with multi OSs - no waiting.

--------------------

DrWowe

  • Hero Member
  • *****
  • Posts: 696
    • View Profile
    • http://
Passing command line args in config file
« Reply #11 on: April 10, 2004, 10:30:47 pm »
Quote
One of the greatest things about the C860 is that it has given me a VERY strong incentive to learn more Linux <G>. But it *still* can\'t do everything that my ancient HP200LX did .... yet .... <G>.

In that case, I recommend installing DosBox or Bochs, and feeding it an image of your HP200LX Rom.  

doc

  • Full Member
  • ***
  • Posts: 191
    • View Profile
    • http://
Passing command line args in config file
« Reply #12 on: April 15, 2004, 09:22:50 pm »
I put a disclaimer on it lardman.  Don\'t want anyone to be mad it was just a joke.  Btw...I visited Bath in 2001.  Very cool town.  I loved the flats in those curved rows of buildings...what was that called?  Stopped by there on my way from London through, Stonehenge, and on to Stratford.  Cheers.
By your command...

Doc
Sharp SL-5500 PDA
Sharp 2.78 ROM
Viking 256MB SD
Socket LP-E CF Ethernet