LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-25-2003, 01:27 PM   #1
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,104

Rep: Reputation: 45
Suitable place to run bash scripts


Hi guys,

I've just created a simple bash script to copy a directory from a mounted Windows filesystem to a directory in my home directory in Red Hat 9.

I,ve then added a command to the bottom of ~/.bash_profile to automatically run the script after login.

It all works fine and I'm happy with it - basically I log in - then it takes about 10 seconds for the directory to copy over (its 200mb's roughy) - then finally the Red Hat desktop loads - sure enough my updated directory has been copied over and is on my Red Hat desktop - that's fine

However - is this the best file to run the script from? - is there a more typical file later in the start process that might be more useful to run this script from? - Is ~/.bash_profile the typical place you'd run start scripts from for an individual user?

I must stress it works fine - I'm just wondering whether there's a file later in the start up process where it would be better to run the script from.
 
Old 08-25-2003, 03:01 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
that's a pretty poor place to run it - every console you open will er do this action.... i'd suggest putting it (with an "&" at the end so it forks iinto the background!) in /etc/rc.local or a similar one off script....

but this action sounds extremely pointless.... why not just create a symlink to the windows directory to wherever you want it.... you sem to have come up with a very bizarre solution to a trivial problem...
 
Old 08-25-2003, 04:13 PM   #3
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Why not just create a cron job even, to run the script at a particular day/time (like when your most likely not using the system so you don't see a lapse of performance decrease)...

But other than that, I wouldn't run a script like that every time I login.. that would get annoying to me.
 
Old 08-25-2003, 04:15 PM   #4
Strike
Member
 
Registered: Jun 2001
Location: Houston, TX, USA
Distribution: Debian
Posts: 569

Rep: Reputation: 31
Why not just mount the directory in your home directory as well?
 
Old 08-25-2003, 04:15 PM   #5
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,104

Original Poster
Rep: Reputation: 45
Acid - it was never a "problem" - I've already got a symlink on the Red Hat desktop to a directory above it ie "windows" - it was a trial learning exercise - nothing more - one question though - would it be the case that in opening a bash shell, the bashrc file checks back to the bash profile file causing the script to run every time I open a bash shell?

TIA

Last edited by Skyline; 08-25-2003 at 04:20 PM.
 
Old 08-25-2003, 04:24 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
Yes, unless i'm very much mistaken. I know that sometimes some user specific scripts aren't sourced, but i'd be quite sure the that one is used every time.
 
Old 08-27-2003, 06:36 AM   #7
UltimaGuy
Member
 
Registered: Aug 2003
Location: Chennai, India
Distribution: PCLinuxOS .92, FC4
Posts: 840

Rep: Reputation: 32
No, I think that the file .bash_profile is loaded only on login, and .bashrc does not exec it every time you open a shell.

But I too think that this is a very bad place to place the shell. You can try to use cron, or may be can place a sym link for the process. But , it is your system and ultimately the decision is yours.
 
Old 01-21-2004, 07:37 PM   #8
fortezza
Member
 
Registered: Mar 2003
Location: Colorado
Distribution: Fedora Core 4
Posts: 297

Rep: Reputation: 30
Runs Every Time

Every time you open a shell, .bashrc will run. I discovered this recently after putting the command to mount a samba share in this file. I started to notice that when I typed "mount" if would should the Samba shares being mounted multiple times. That has been taken out, and I am wondering if I can use if...fi to test if something is already mounted on a particular folder, and only mount the share if nothing is already mounted.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run Bash scripts like thread in Java? nguyenzoro Linux - General 1 11-11-2005 02:08 AM
Cannot run install sh scripts, and bash is FUBAR...what to do? asdfjkl Linux - Software 5 11-20-2004 09:09 PM
How to Run perl scripts using bash Boudewijn Linux - Software 2 11-26-2003 03:37 AM
bash scripts won't run aamehl Linux - General 10 09-06-2003 02:25 PM
Install scripts do not run...BASH# no such command tmera Linux - General 1 12-17-2000 02:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration