Active Topics

 


Reply
Thread Tools
Eismaus's Avatar
Posts: 31 | Thanked: 1 time | Joined on Oct 2007 @ Germany
#1
I hope someone can give me a few good pointers.

I have googled the standart shell commands. ls is the is the counterpart to dir and so on.
Now, in dos i can write batch files, with would have the ending .bat so my pc knows what to do with them.
While searching the web, i read it would be .sh in linux, but it didn't work for me.

What file extension do i need for linux?

To be sure, there are no file links, I tried notesm, leafpad and PyTKEditor for writing the scripts.
Also, on some messed up pc's i have to tell windows, that .bat files are executet in the comandline..

Do i have to make such a conection on my N800 too?

I have installed xterm and i can access root with "sudo gainroot" ..
Haven't done much more until know, because i want to understand what i do, before i messed up.

Thanks for your help,
Eismaus
 
Posts: 76 | Thanked: 5 times | Joined on Jul 2006
#2
The extension doesn't matter (although .sh is sometimes used).

What is missing is the correct permission on the file, you need to do something like this:
chmod ugo+x somescript

meaning set eXecutable attribute for the file's User,Group and Other (i.e. everyone) users. The other attributes are r=Read and w=Write, which can all be set independently for the User, Group and 'Other'.

Additionally, the filesystem that holds the file needs to be executable - the memory card is not, so that command would not help for files stored there.

One other pitfall if you're used to DOS, the current directory is NOT part of the path searched for executables (for security reasons). So you need to specify a path to run the script even if it's in the current directory.

It can be a relative path, so this will do:

./somescript
 
dormant's Avatar
Posts: 332 | Thanked: 76 times | Joined on Oct 2007 @ St. Augustine, Trinidad and Tobago
#3
In Linux scripts, the first line tells the script what interpreter to use, using a special "#!" syntax. To the unaware, it looks like a comment line.

On the n800 etc, a script using sh would start like this:

#!/bin/sh
__________________
  • N900
  • N800
  • LD-3W
  • two magic OTG USB adapters
  • crossed fingers

Last edited by dormant; 2007-11-11 at 16:45.
 
Posts: 3,841 | Thanked: 1,079 times | Joined on Nov 2006
#4
Originally Posted by paulh View Post
chmod ugo+x somescript

meaning set eXecutable attribute for the file's User,Group and Other (i.e. everyone) users. The other attributes are r=Read and w=Write, which can all be set independently for the User, Group and 'Other'.
.. which can be shortened to just 'chmod a+x somescript' (a = all)
__________________
N800/OS2007|N900/Maemo5
-- Metalayer-crawler delenda est.
-- Current state: Fed up with everything MeeGo.
 
Posts: 193 | Thanked: 41 times | Joined on Jan 2007 @ Paia, Maui, Hawaii
#5
Originally Posted by Eismaus View Post
...
I have googled the standart shell commands...
Hi Eismaus:
I am using linuxcommand.org's reference to brush up on shell commands etc:
online version
downloadable version
 

The Following User Says Thank You to ichmoimeyo For This Useful Post:
Eismaus's Avatar
Posts: 31 | Thanked: 1 time | Joined on Oct 2007 @ Germany
#6
@ichmoimeyo Thanks for the links, i downloaded the file and i'll read it on my way to work tomorrow.

@dormant I had #!/bin/bash because my live-cd used this. I corrected it.

@paulh & @TA-t3 So i have to make the file executable first. And i could not save the script on the memory card. Ok, this i understand.
Saving the file in the MyDokuments wouldn't work too, would it?

But I'm not sure if i understand, what you mean with :
Originally Posted by paulh View Post
One other pitfall if you're used to DOS, the current directory is NOT part of the path searched for executables (for security reasons). So you need to specify a path to run the script even if it's in the current directory.

It can be a relative path, so this will do:

./somescript
Do i have to put the path into the script? or do i need it when i execute the script?

What i was trying to do. Save the skript as a file and execute it with a pen tab/klick.

Thanks again for the help!
Eismaus
 
Posts: 3,841 | Thanked: 1,079 times | Joined on Nov 2006
#7
- Programs and scripts are executable anywhere on the internal flash, so in MyDocuments would work too.
- You need the path to the file when you execute the script, unless the directory where the script resides is in the PATH environment variable.

You can check the current value of the environment variable with
Code:
env | grep PATH
(ignore GTK_PATH, you're just interested in PATH).
It's probably something like bin:/usr/bin
(I'm not certain what the default path is, because I have changed mine. More on that below.)

Now, it's possible to extend the default path. You could make a directory $HOME/bin (which is the same as /home/user/bin) with 'mkdir', and put your script(s) there. If you create or edit the file .profile (note leading dot) in the home directory and add the line
Code:
PATH=$HOME/bin:$PATH
then all scripts put in /home/user/bin/ will be executable without having to specify the path, e.g. just 'somescript.sh'.

But then you wanted to execute the script by just a stylus click.. that was more tricky! But I seem to remember someone had hacked together a little applet or other gui program to just execute commands or scripts -- maybe they will step forward?
__________________
N800/OS2007|N900/Maemo5
-- Metalayer-crawler delenda est.
-- Current state: Fed up with everything MeeGo.

Last edited by TA-t3; 2007-11-13 at 11:21. Reason: typo
 
Eismaus's Avatar
Posts: 31 | Thanked: 1 time | Joined on Oct 2007 @ Germany
#8
Ah, now it is clear. Thanks for the explantion.

I have successfully written an easy script with i can execute from the shell.
The next step is to mapp and unmap my work/Home direktory with a script.

If someone have more information about this applet/programm, please tell?

Thanks all for your help.
Eismaus
 
technut's Avatar
Posts: 574 | Thanked: 166 times | Joined on Oct 2007 @ BC, Canada
#9
Get an app called "load-applet-run". It creates an icon in the status bar and you can add run commands to the dropdown list. It's also just a nice icon/app that shows time, CPU and memory graphs too... worth having.

http://downloads.maemo.org/product/load-applet-runn/

Works fine on my N800.
 
technut's Avatar
Posts: 574 | Thanked: 166 times | Joined on Oct 2007 @ BC, Canada
#10
I may have named the wrong applet above... the one I was thinking of is "Clockified osso-statusbar-cpu".
http://maemo-hackers.org/wiki/OssoStatusbarCpu
 
Reply


 
Forum Jump


All times are GMT. The time now is 10:16.