Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 30 Sep 2014, 12:29
All times are UTC - 4
 Forum index » House Training » Beginners Help ( Start Here)
Basic Shell (Console) operation for beginners
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 20 of 24 [350 Posts]   Goto page: Previous 1, 2, 3, ..., 18, 19, 20, 21, 22, 23, 24 Next
Author Message
eriksatie

Joined: 06 Jun 2011
Posts: 41

PostPosted: Wed 08 Jun 2011, 14:27    Post subject:  

Bruce B wrote:


Here is a very simple script that won't seem to work. Please try it.

Scriptname r
Code:
#!/bin/bash
cd /


After you've made it executable, run it.


How do I make a script and make it executable?
Back to top
View user's profile Send private message 
Bruce B


Joined: 18 May 2005
Posts: 11109
Location: The Peoples Republic of California

PostPosted: Wed 08 Jun 2011, 18:35    Post subject:  

eriksatie wrote:
How do I make a script and make it executable?


I guess that wasn't mentioned. I'll come back and make a thorough reply.

In the meantime chmod 755 scriptname will suffice

~

_________________
New! Puppy Linux Links Page

Last edited by Bruce B on Wed 08 Jun 2011, 22:13; edited 1 time in total
Back to top
View user's profile Send private message 
rcrsn51


Joined: 05 Sep 2006
Posts: 9145
Location: Stratford, Ontario

PostPosted: Wed 08 Jun 2011, 20:32    Post subject:  

Quote:
In the meantime chown 755 scriptname will suffice

I believe you mean
Code:
chmod 755 scriptname
Back to top
View user's profile Send private message 
Bruce B


Joined: 18 May 2005
Posts: 11109
Location: The Peoples Republic of California

PostPosted: Wed 08 Jun 2011, 22:13    Post subject:  

rcrsn51 wrote:
Quote:
In the meantime chown 755 scriptname will suffice

I believe you mean
Code:
chmod 755 scriptname


I did. Thank you very much. I'll edit the original.

This is one reason why the open source model works, peer review.

~

_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
SimpleWater

Joined: 19 Apr 2011
Posts: 95

PostPosted: Sat 11 Jun 2011, 17:07    Post subject:  

Code:
chmod +x scriptname


that works fine for me, also easier to remember than numbers and fewer characters too
Back to top
View user's profile Send private message 
rhadon


Joined: 27 Mar 2008
Posts: 1293
Location: Germany

PostPosted: Wed 22 Jun 2011, 12:23    Post subject:  

Hi,

inspired by this thread, I tried to solve it by my own.
btw. I think this feature could be worth to be integrated in all new puppies. Wink

These are the relevant lines (thanks DaveS):
Code:
read -t 5 NUMSAVE
 [ -z "$NUMSAVE" ] && NUMSAVE=1

I want to substitute both values (5 and 1) by values from a textfile.

I built a textfile named "boot-savefile" with:
Code:
time=10
default=2


From console, I get access to the file with
Code:
#grep "time=" boot-savefile | cut -f 2 -d '='
10
#grep "default=" boot-savefile | cut -f 2 -d '='
2
#


I made a simple script for testing:
Code:
TST1=grep "time=" boot-savefile | cut -f 2 -d '='
echo $TST1


I tried now for 2 days, several hours a day, to get this working. No chance. No matter what I tried, and I really tried a lot.

Maybe I don't see the trees for the wood. Where am I wrong?

Thanks
Rolf

_________________
Ich verwende "frugal", und das ist gut so. Wink
Raspberry Pi without Puppy? No, thanks.
Back to top
View user's profile Send private message 
Bruce B


Joined: 18 May 2005
Posts: 11109
Location: The Peoples Republic of California

PostPosted: Wed 22 Jun 2011, 12:34    Post subject:  

Rolf,

Please post the names save files on your list in order from top to bottom.

Please tell me if there is a default, such as the one at the top.

Please zip init if you are not using Lupu 5.20

Bruce

~

If you don't know how to open initrd.gz tell me

_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
rhadon


Joined: 27 Mar 2008
Posts: 1293
Location: Germany

PostPosted: Wed 22 Jun 2011, 13:23    Post subject:  

Bruce,

the code from DaveS works fine. I can change the time or the default savefile. But every time I want to change something, like I want another savefile by default, I have to edit the initrd.gz. I know how to do but it's annoying. It is much easier to edit a simple textfile. That's the actual reason for me, digging in bash programming.

I now use Lupu 5.25 and I think it's equal to 5.20
the original part of init ~line 782:
Code:
     read NUMSAVE
    [ $NUMSAVE -ne 0 ] && PUPSAVE="`cat /tmp/PUPSAVE2SFSS | tr '\n' ' ' | cut -f $NUMSAVE -d ' '`"


changed to:
Code:
read -t 5 NUMSAVE
  [ -z "$NUMSAVE" ] && NUMSAVE=1
    [ $NUMSAVE -ne 0 ] && PUPSAVE="`cat /tmp/PUPSAVE2SFSS | tr '\n' ' ' | cut -f $NUMSAVE -d ' '`"
As I wrote, it works fine but with values from a external textfile it would be great.

For now my savefiles are: lupusave.3fs, lupusave-compile.3fs and lupusave-dummy.3fs. I don't think, it is important.

Rolf

_________________
Ich verwende "frugal", und das ist gut so. Wink
Raspberry Pi without Puppy? No, thanks.

Last edited by rhadon on Thu 23 Jun 2011, 01:48; edited 1 time in total
Back to top
View user's profile Send private message 
Bruce B


Joined: 18 May 2005
Posts: 11109
Location: The Peoples Republic of California

PostPosted: Wed 22 Jun 2011, 13:34    Post subject:  

Rolf,

I thought you wanted help. I'll offer a suggesiton that made it more enjoyable for me

-n 1 saves from entering the selection then the enter key - just enter the selection

try it

Bruce

~

_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
rhadon


Joined: 27 Mar 2008
Posts: 1293
Location: Germany

PostPosted: Wed 22 Jun 2011, 15:50    Post subject:  

Bruce,

I don't understand:
Quote:
-n 1 saves from entering the selection then the enter key - just enter the selection


Yes, I want help, and for 2 times I tried my very best to explain what I want and where I'm struggling.

OK, maybe step by step. Please forget everything before.

I have a textfile named boot-savefile with:
Code:
time=10
default=2


And a script:
Code:
TST1=20
echo $TST1

gives the expected result: 20. OK.

Typing in console:
Code:
grep "time=" boot-savefile | cut -f 2 -d '='

gives the expected result: 10

In the script:
Code:
TST1=grep "time=" boot-savefile | cut -f 2 -d '='
echo $TST1


doesn't work. Also everthing I tried to get it work, failed.

What is wrong, please?

It seems to be a stupid, basic problem of misunderstanding from me.

Rolf

Edit: OK, I got it. Very Happy
Code:
TST1=$(grep "time=" boot-savefile | cut -f 2 -d '=')
Works.

Thanks for trying to help.

_________________
Ich verwende "frugal", und das ist gut so. Wink
Raspberry Pi without Puppy? No, thanks.
Back to top
View user's profile Send private message 
Bruce B


Joined: 18 May 2005
Posts: 11109
Location: The Peoples Republic of California

PostPosted: Thu 23 Jun 2011, 08:02    Post subject:  

rhadon wrote:
In the script:
Code:
TST1=grep "time=" boot-savefile | cut -f 2 -d '='


Sorry I wasn't on the same page with you.

I'll offer a tip for the future when setting variables such as the one above.


Commonly we use backtics
Compare first line, which won't work, with the second, which will work

TST1=grep "time=" boot-savefile | cut -f 2 -d '='
TST1=`grep "time=" boot-savefile | cut -f 2 -d '='`

I can't define what the backtics do in every scenario, but in this case, I explain it is saying; move the results of my commands from right to left into the variable.

Bruce

~

_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
rhadon


Joined: 27 Mar 2008
Posts: 1293
Location: Germany

PostPosted: Thu 23 Jun 2011, 11:10    Post subject:  

Thanks for clarification, Bruce.

I just learned again that it's always good, thinking twice or more before posting. Laughing

Just before telling you that I tried backtics several times and it doesn't work, I realised that I always used normal tics (I hope that's the right term), as ' instead of `. Embarassed

So another mystery is solved for me.

Thanks,

Rolf

_________________
Ich verwende "frugal", und das ist gut so. Wink
Raspberry Pi without Puppy? No, thanks.
Back to top
View user's profile Send private message 
Bruce B


Joined: 18 May 2005
Posts: 11109
Location: The Peoples Republic of California

PostPosted: Thu 23 Jun 2011, 14:57    Post subject:  

Quotes and apostrophes work also and are frequently used when setting variables. The key is to know what they do.

Here is something for you to copy and paste to your console if you want to see the effects. One command at a time from top to bottom.

myvar='echo $PATH'

$myvar

myvar="echo $PATH"

$myvar

myvar=`echo $PATH | cut -d : -f 1-3`

$myvar

unset myvar


~

_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
rhadon


Joined: 27 Mar 2008
Posts: 1293
Location: Germany

PostPosted: Fri 24 Jun 2011, 03:48    Post subject:  

Thanks again, I got it.

I was playing with the cut command for better understanding. So I changed the delimiter to /.

Now there's a difference between running this command directly or moving the result of the command into myvar and then asking the value of myvar.


Code:
# echo $PATH | cut -d / -f 1-5
/bin:/usr/bin:/sbin:

# myvar=`echo $PATH | cut -d / -f 1-5`
# $myvar
bash: /bin:/usr/bin:/sbin:: No such file or directory
#


Shouldn't both kinds give identical results? OK, the result is equal, but why no comment above?


Another question. I've built a small script which seems to work fine. But adding it to the init script of initrd doesn't work. I think I know why, but not how to solve. For now I will try to find it out by myself. A new day, new ideas ...and so on.

If I can't solve this for me, is it OK to post such questions here (maybe initrd isn't so interesting for others here) or should I post in a separate thread, maybe in Users ( For the regulars )?

Rolf

Edit: Aaarrrggg... I hate typos but typos love me. edited the third time Embarassed

_________________
Ich verwende "frugal", und das ist gut so. Wink
Raspberry Pi without Puppy? No, thanks.
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 7805
Location: qld

PostPosted: Fri 24 Jun 2011, 04:51    Post subject:  

Hi Rolf

I saw this before dinner but I thought I'll let it go for a little while..

echo "$myvar"

It works without the double quotes too.

Cheers

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 20 of 24 [350 Posts]   Goto page: Previous 1, 2, 3, ..., 18, 19, 20, 21, 22, 23, 24 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Beginners Help ( Start Here)
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1006s ][ Queries: 13 (0.0103s) ][ GZIP on ]