linux (Fedora) command only line app

Deploying to Linux? Get penguinated here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

linux (Fedora) command only line app

Post by n.allan » Sat Dec 06, 2008 3:18 pm

I am new to linux and have decided to start from the ground up. I have installed Fedora 8 with no GNOME or KDE interface only command line. I want to create a standalone that simply returns a string to stdout with no GUI. Is this possible and if so where should it be handled in the script?

on startUp
on preOpenStack etc...

any help would be appreciated.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Post by mwieder » Sun Dec 07, 2008 3:48 am

Just write your string to stdout. You may want to use the -u commandline argument when you start the app. I could have sworn the commandline arguments were documented somewhere but I can't seem to find them now.

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Post by n.allan » Mon Dec 08, 2008 12:58 pm

Hello mweider! You always seem to come to my rescue. That's what I have been doing.

on startUp
write "Hello World" to stdout
quit
end startUp

Do I need the quit command in there?

Over the weekend I did it in c++ after hours of figuring out how to install gcc etc... It turns out after I had compiled the app using gcc I just tried to run it from the command line as follows:

$ g++ test.cpp -o test --compile the app
$ test --nothing happens
$ ./test
Hello World --BINGO!
it needed the ./ something to do with home directory I think?! But I would still like to do it in rev. I'll have a bash tonight after my HangOver has gone from the works night out!

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Post by mwieder » Mon Dec 08, 2008 5:32 pm

In linux the concept of the "current directory" is not necessarily part of the path for executables. Thus the need to prefix the app name with "./" in order to make it a complete absolute path the the application. Alternately, you could move the app to some directory in your path and then you could execute it from anywhere.

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Post by n.allan » Thu Dec 11, 2008 10:19 pm

Even with the rev app in my bin directory, I am still not having much luck. It works with my c++ "Hello World" app but not with my rev one. I reeeealy don't want to tackle this app in c++.

I would appreciate a small snippet of code to get a simple "hello world" using rev at a linux command line. I can take it from there. So far I have tried:

on preOpenStack --(and on startUp)
write "Hello World" & lf to stdout
quit
end preOpenStack --(or startUp)

Nothing happens. I have also tried redirecting the output to a text file:
helloworld > helloworld.txt but nothing is in the file. Am I missing something?

Perhaps I need to have GNOME or KDE installed to use rev at all in linux? I can't just have good ol' UNIX style command line? I suppose I could install GNOME and just not use it? Would the rev app still work?

Ahh... Maybe I need to upgrade to the latest Fedora, I'm using Fedora 3?!?

SparkOut
Posts: 2857
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Thu Dec 11, 2008 10:58 pm

By starting (a standalone) from a console command with

Code: Select all

./StandaloneName -u
and using a stack with the code

Code: Select all

on openStack
  put "Hello world"
  quit
end openStack
I got my "Hello world" returned to the command line.

(Now what I'd like is to be able to start it in a kde windowed environment via VNC, where the max bit depth is 24, and finding out how to avoid an error
error message wrote:_X11TransSocketINETConnect() can't get address for MyMachineName.local:6001 Name or service not known
<path>: Can't open display MyMachineName.local:1.0
)

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Post by n.allan » Fri Dec 12, 2008 12:29 am

Thanks for that! It worked although I found I had to chmod the file before it would let me run it. Thanks again, back to the grind!
Now what I'd like is to be able to start it in a kde windowed environment via VNC, where the max bit depth is 24, and finding out how to avoid an error
Indeed :->

SparkOut
Posts: 2857
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Fri Dec 12, 2008 9:21 am

Just for the record, I changed my script to

Code: Select all

on openStack
  put "Hello World via put"
  write "Hello World via writing to stdout" & cr to stdout
  put "Hello World via put again"
  write "Hello World via stdout again" & lf to stdout
end openStack
All strings printed to the console OK, with cr or lf appropriately used.

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Post by n.allan » Fri Dec 12, 2008 4:45 pm

Talking command line arguments. I found that if I passed certain arguments such as -u - r to my rev app they will not appear in my $ variables inside the standalone. Everything else does such as -p/dev/ttyUSB0 but it seems to skipp any ones that the rev engine has used.

so if I start my app:

HelloWorld -u -p/dev/ttyUSB0 -r -anotherVar

My vars would contain
$0 -p/dev/ttyUSB0 --as expected
$1 -anotherVar --not expected (should be -r)

It would be great to have a list of command line args for the rev engine so that we can be carefull NOT to use these in our own standalones.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Post by mwieder » Fri Dec 12, 2008 5:00 pm

Here's the list as of the rev 2.6.1 engine (2004). I don't know whether these have changed since then:

MetaCard 2.6.1 Copyright 1992-2001 MetaCard Corporation
Usage: /home/mark/projects/revolution/ide/wip/revolution.x86
[-d[isplay] displayname]
[-f[iles] (disable access to files and processes)
[-g[eometry] ={+-}<xoffset>{+-}<yoffset>]
[-i[nput] fd] read commands from fd (0 is stdin) or named pipe
[-m[map]] (don't memory map files)
[-n[opixmaps]] (draw direct to screen)
[-p[ointerfocus]] (use active focus)
[-s[haredoff]] (don't use shared memory server extension)
[+s[haredon]] (use shared memory server extension)
[-u[i]] (don't create graphical user interface)
[-v[isualid] n] (use visual id n as listed from xdpyinfo)
[-w[indowid] n] (watch window id n for commands)
[stackname(s) | argument(s)]

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Post by n.allan » Fri Dec 12, 2008 5:15 pm

Thanks for that, That's a very handy list!

Post Reply

Return to “Linux”