boot to My Directory using sh Script

Status
Not open for further replies.
I

iic2

Guest


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

Administrator
Staff member
Administrator
Moderator

Reaction score: 1,259
Messages: 4,099

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?
 
OP
OP
I

iic2

Guest


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

Daemon

Reaction score: 502
Messages: 2,228

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

Why don't you just add
Code:
cd bin
ls -l
to your (root's) csh resource script file (/root/.cshrc)?
 
OP
OP
I

iic2

Guest


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

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,751
Messages: 30,832

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
 
OP
OP
I

iic2

Guest


I type this in the as the last line in my script.
Code:
echo dump_root
No success

So I type this at command-line
Code:
echo dump_root
dump_root
#
It return the prompt instantly, while only show name of file.


I type this at command-line
Code:
(t)csh: setenv PATH $PATH:/root/bin/bin
Bad : modifier in $ ( )

So I type this at command-line
Code:
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:
Code:
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

Administrator
Staff member
Administrator
Moderator
Developer

Reaction score: 2,816
Messages: 11,305

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".
 
OP
OP
I

iic2

Guest


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
 
OP
OP
I

iic2

Guest


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.cgi?fetch=107264+0+/usr/local/www/db/text/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
 
Status
Not open for further replies.
Top