Author Topic: writing & running scripts  (Read 3136 times)

Anonymous

  • Guest
writing & running scripts
« on: May 27, 2004, 01:50:18 am »
i have been wondering how to do this for about a month

is there a certain program that i need to write them with?

and where do they go & how do i put them there?

an i guess lastly how would i run the scripts?

if there is a faq that explains this clearly it certainly has gotten mixed in with a ton of other stuff  on here.

:] thankx
-terrorphile

Anonymous

  • Guest
writing & running scripts
« Reply #1 on: May 27, 2004, 01:51:45 am »
also is there a chat anywhere for primarily zaurus users?

freizugheit

  • Sr. Member
  • ****
  • Posts: 409
    • View Profile
    • http://
writing & running scripts
« Reply #2 on: May 27, 2004, 03:29:24 am »
Please register and it does not cost you $.

Which machine are you using?  What have you been using in these days?

What level is your Unix knowledge?  Which script are you interested: shell, Python, etc.

terrorphile

  • Newbie
  • *
  • Posts: 44
    • View Profile
writing & running scripts
« Reply #3 on: May 27, 2004, 03:36:54 am »
i\'m using an sl 5500 w/ the sharp rom

an i\'m just trying to find out how to write & run scripts for the zaurus

i dont have much knowledge of unix at all

thats why i\'m asking

i guess it would be a shell script

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
writing & running scripts
« Reply #4 on: May 27, 2004, 06:29:34 am »
A shell script is a text file. Create it with \'vi\' (if you\'re running the standard ROM, you may find that the graphical text editor adds line to make it compatible with Windows, but Linux doesn\'t like it). There are also other graphical editors which you could install and use which will not cause this problem.

Scripts can go anywhere. If they are in the PATH (type \'export\' at the command prompt and see the list of directories in the PATH variable) then you can just write the name at the command prompt and the script will run. If it\'s not in the path then you either have to write the entire path:

# /path/to/my/script

Or change to the script\'s directory and run it from there like so:

# cd /path/to/my
# ./script

As I said earlier a script is just a text file, with the following line at the top (assuming you want a shell script):

#! /bin/bash

or it could have

#! /bin/sh

There are other types of script, which may use other programs to run them. For example (I think) a perl script can start like this:

#! /usr/bin/perl

Take a look here for how to actually write the contents of scripts:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/abs/html/index.html

Let us know how you get on.


Si
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

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
writing & running scripts
« Reply #5 on: May 27, 2004, 06:32:03 am »
I\'ve got a quick question now:

#! /bin/bash

or

#!/bin/bash

I believe one is correct and the other isn\'t, even though both work.

Which way round is it?

Cheers,


Si
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

Optogeek

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • http://optogeek.homelinux.net
writing & running scripts
« Reply #6 on: May 27, 2004, 07:36:46 am »
I think it is the second, the one without the space.
SL-C860 running Cacko 1.23
SL-5500UK with 3.13 Sharp ROM + Cacko Kernel
Origo WLAN and BlueMonkey BT CFs
1GB Crucial SD
1GB Crucial CF

Optogeek

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • http://optogeek.homelinux.net
writing & running scripts
« Reply #7 on: May 27, 2004, 07:56:39 am »
Just cheched.  It is the second without the space.  The first will still seem to work on the Zaurus properly because the the rest of the script is run by the original shell, which on a Zaurus is nearly always sh clone, as a shell function (like a script but without an interpretting shell).
SL-C860 running Cacko 1.23
SL-5500UK with 3.13 Sharp ROM + Cacko Kernel
Origo WLAN and BlueMonkey BT CFs
1GB Crucial SD
1GB Crucial CF

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
writing & running scripts
« Reply #8 on: May 27, 2004, 09:37:44 am »
Hmm, I\'m not sure. I thought I read a long long time ago that there was actually supposed to be a space, but that most people don\'t put it in.

Anyway whichever one you use it tends to work on everything I\'ve used.


Si
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

bluey

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • http://
writing & running scripts
« Reply #9 on: May 27, 2004, 09:50:04 am »
Both do, when you run it (chmod +x file.sh) by ./file.sh it uses the interpreter which can be sh, bash, perl, whatever, if you call it with sh file.sh, it will be run by that instance of the shell you create, and #!/path/to/interpreter is treated as a comment.


Hmmm, I can be wrong, though
SL-5500 - OZ 3.5.3
256Mb Kingston SD Card
64Mb PQI CF Card
Netgear MA701 WiFi CF Card
Mandriva GNU/Linux LE2005
Dreaming of a C model...

ScottYelich

  • Hero Member
  • *****
  • Posts: 992
    • View Profile
    • http://www.zaurususergroup.com/modules.php?opmodload&namephpWiki&filei
writing & running scripts
« Reply #10 on: May 27, 2004, 09:58:24 am »
Quote
also is there a chat anywhere for primarily zaurus users?


irc.freenode.net

#zaurus

#cacko

perhaps others (#openzaurus, #openembedded?)

Scott