# boot to My Directory using sh Script



## iic2 (Apr 8, 2009)

I want show all files in my bin directory at start-up.  Its in  /root/bin
So that each time I reboot this directory will open.  Would anyone have a sh script for doing this and show how I would use it.  I'm reading Practical rc.d scripting in BSD also but a working example of this type would help me to more to understand what i'm reading.

Thanks in advance


----------



## phoenix (Apr 8, 2009)

Do you want a dump of the directory contents to the screen, during boot-up, before the login prompt appears?  Just edit /etc/rc.local and put *ls -l /path/to/wherever* for that.

Or are you trying to do something else?


----------



## iic2 (Apr 8, 2009)

I didn't see any rc.local in /etc or /etc/rc.d so I created the file in /etc/rc.d and named it rc.local ...... "ls -l /root/bin"


When I re-booted ALL my bin file were all listed before log-in.  So that's what you mean by dump to screen 

But that was not what I mean.  This is the idea:

When ever we start our machine it is default to /root

I want to set default to another directory like /root/bin or usr/home and have the machine boot to there every time at start up.  This way i don't have to type anything in the command line.  

Thanks phoenix_rizzen

PS: After this I'll have one more final question for a long time and I need a  little more information about my "cd to sub-folder on Flash using Script" question.  After that I'll be all set.  I hate to boar everyone with all of my newbee questions.   When I am able to do all three things than I'll be able to explore the OS more safely, quickly and easily.  Than I can begin to learn how to do things on my own for a while.  That's my only goal for now.  A set-up of convenience to replace some typing power to reserve some brain power.  All that typing cause me to forget my next steps sometime.  I love sh scripts.


----------



## Beastie (Apr 9, 2009)

You mean you want this to happen when you have already logged in, right?

Why don't you just add

```
cd bin
ls -l
```
to your (root's) csh resource script file (/root/.cshrc)?


----------



## iic2 (Apr 10, 2009)

Thanks Beastie, That's it.  It WORKS
btw, I used to study someone named Beastie sample assembler code at the original (Hiro) board.win32community years ago.  Is that you?
...........................
...........................

May I also ask here.  Can we have more than one bin in root like this:

/root/bin	This works
/root/bin1	don't work
/root/bin2 	" "
/root/bin3	" "

I create this file in bin and it works.  I double click uhistory. Right click to paste.  Hit enter and the file opens

#1 /bin/sh
ee /root/.history

chmod 700 uhistory
rehash
...........................
...........................
I do the exact same thing below for another file in bin1, but I get
ucshrc: Command not found.

#1 /bin1/sh
ee /root/.cshrc

chmod 700 ucshrc
rehash
...........................
...........................
Don't seem like sh allow nothing to execute unless it's in a directory call bin.  I even made a sub-directory with the file in it /root/bin/bin but I did not know how to use forward or back slashs properly i guest if this was possible anyway.

Would anyone know the syntax to force execution of files in other bins in the same root directory?


----------



## SirDice (Apr 10, 2009)

iic2 said:
			
		

> Don't seem like sh allow nothing to execute unless it's in a directory call bin.


echo $PATH



> I even made a sub-directory with the file in it /root/bin/bin but I did not know how to use forward or back slashs properly i guest if this was possible anyway.
> 
> Would anyone know the syntax to force execution of files in other bins in the same root directory?


(t)csh: setenv PATH $PATH:/root/bin/bin
sh: PATH=$PATH:/root/bin/bin; export PATH


----------



## iic2 (Jun 11, 2009)

I type this in the as the last line in my script.

```
echo dump_root
```
No success

So I type this at command-line

```
echo dump_root
dump_root
#
```
It return the prompt instantly, while only show name of file.


I type this at command-line

```
(t)csh: setenv PATH $PATH:/root/bin/bin
Bad : modifier in $ ( )
```


So I  type this at command-line

```
sh: PATH=$PATH:/root/bin/bin; export PATH
Bad : modifier in $ ( )
```

What am I'm doing wrong?  These are the same results I got back in April so I gave up.  Now I needed it cause I got too many scripts inside one folder and need to create another

Thanks in advance

Here is the script i'm trying to run:

```
cat /root/dumpfs.sh
#!/bin/sh
fl=`date "+%d-%m-%Y"`
path="/H/backup/dumpfs"

#root file system
/sbin/dump  -0 -L -f - /dev/ad4s1a > $path/rootfs/dump_ad4s1a_${fl}.img
tar cfz $path/rootfs/dump_ad4s1a_${fl}.tar.gz $path/rootfs/dump_ad4s1a_${fl}.img
rm -f $path/rootfs/dump_ad4s1a_${fl}.img
chmod 400 $path/rootfs/dump_ad4s1a_${fl}.tar.gz
```


----------



## DutchDaemon (Jun 11, 2009)

1. 'echo' just shows what's right behind it, in your case 'dump_root'. Try 'echo washing machine', and you'll know what echo does. Maybe you mean 'ls -al dump_root' or 'cat dump_root' or 'echo $dump_root' (if it's a variable you defined somewhere)?

2. did you actually type '(t)csh:' and 'sh:' as part of those commands? Don't. It meant "use the following command in (t)csh or sh, whichever applies to you".


----------



## iic2 (Jun 11, 2009)

Yes I did, but I did eventually type it in correctly but got same results... I don't know no better yet   But I have finally learned my way around the system.  I think i know where everything is 

I just edit that post to show what I am trying to do.

Thanks


----------



## iic2 (Jun 13, 2009)

Now I get it DutchDaemo.  No wonder.  It's not magic.  I didn't even make proper changes to the file.  hee hee.  I started out with  killasmurf86 code and now understand how most of it works, yet I been having problems with restore.    I think I'll keep a list of thread that details some of the fancy stuff.  Here a few that are simply to good to forget:

killasmurf86 BACK-UP
http://forums.freebsd.org/showthread.php?t=185

phoenix Remote Backup
http://forums.freebsd.org/showthread.php?t=3689

Backup entire system
http://forums.freebsd.org/showthread.php?t=4901

USB Backup
http://docs.freebsd.org/cgi/getmsg....2006/freebsd-hackers/20060326.freebsd-hackers

How can I make the entire disk empty:
http://forums.freebsd.org/showthread.php?t=518

resize when NOT in single user mode:
http://forums.freebsd.org/showthread.php?t=4899

creating new partition-fdisk-Exam content:
http://forums.freebsd.org/showthread.php?t=3304&highlight=format+slice

mtree:
ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/7.2-RELEASE/base/base.mtree

ROUTERS:
http://forums.freebsd.org/showthread.php?t=405&highlight=FreeBSD+router

CUSTOM KERNEL:
http://forums.freebsd.org/showthread.php?t=4146


----------

