LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 12-15-2011, 06:26 PM   #1
corbinc
LQ Newbie
 
Registered: Dec 2011
Posts: 5

Rep: Reputation: Disabled
Run a command at login


As a user, how can I run the following command (to start dropbox) everytime I login?

~/.dropbox-dist/dropbox &

I am on open suse 11.4, soon to be 12.1

I was browsing the forums and saw a post from years ago that solved it by adding the command to etc/rc.local, however I can't find that file and when i try to cd there, it says file does not exist.

If you need any more info let me know.

thanks
 
Old 12-15-2011, 06:36 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,653
Blog Entries: 2

Rep: Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097
If you want it to start when the user logs in (which would be a good thing with dropbox) rather than being launched when the machine starts (which would be the case when you put that in rc.local) just add the command to your ~/.bashrc file.
 
Old 12-15-2011, 06:43 PM   #3
corbinc
LQ Newbie
 
Registered: Dec 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TobiSGD View Post
If you want it to start when the user logs in (which would be a good thing with dropbox) rather than being launched when the machine starts (which would be the case when you put that in rc.local) just add the command to your ~/.bashrc file.
I dont have a .bashrc file in my home directory (all i have access to), i do however have a .cshrc, is that the same thing? If so what is the syntax for adding the command in there? Or do i literally just type the command in there?

here is the contents of the .cshrc file:

#
# Standard .cshrc file for new accounts
#

# If you want the system to shut up (i.e. skip all of the
# xxxxxx added to environment messages at login), uncomment the next line
setenv QUIET 1

# The following lines set up a default, generic account which will work on
# all of the supported operating systems in the department. If you want to
# change the set of software available in your account, see the COG web site
# at http://intranet.cs.nmsu.edu/COG/CogDocs/setup.html, comment out the next
# line and see the tail end of this file.
source /local/config/cshrc.standard
source ~/.alias

# Custom configurations
# To customize, comment out the first source line of this file and uncomment
# the section below. Read the COG documentation on customizing your account.
# For the impatient - the setenv statements below register the OS name and
# revision you have logged in on. The if/then/else statements select a
# section based on the OS name and revision. The source statemetns inside
# the branches actually do the work. In this code, they again source the
# default setups, which are different on each OS. A reasonable starting point
# is to log in to the OS for which you wish to customize and replace the
# appropriate cshrc.standard line with the contents of the
# /local/config/cshrc.standard file on that platform, then add and delete
# source lines as needed

#setenv OS_NAME `uname -s`
#
#if( $OS_NAME == "Linux" ) then
# source /local/config/cshrc.standard
#else if ( $OS_NAME == "SunOS" ) then
# # This part is for Solaris
# source /local/config/cshrc.standard
#else
# echo "Unknown Operating System"
#endif
source /home/CS273/cshrc.cs273
 
Old 12-15-2011, 06:54 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,653
Blog Entries: 2

Rep: Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097
If you don't have .bashrc, but you have .cshrc that indicates that you are not using Bash, but csh as shell. I know nothing about .csh, but I would just try to add that command at the end of the file (yes, just type it in).
If that doesn't work try to create a .bashrc and add the command there.
 
Old 12-15-2011, 07:00 PM   #5
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 3,222

Rep: Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155
Putting it in .bashrc will cause it to run every time he opens a terminal. Probably not what he's looking for with dropbox...

OP - you need to be more clear exactly WHEN you want this to run. When the machine first boots up? When the user first logs in in a text session? When the user first logs in in a graphical session? Every time the user opens a terminal? All of these have different solutions and ramifications.

Last edited by suicidaleggroll; 12-15-2011 at 07:02 PM.
 
Old 12-15-2011, 07:03 PM   #6
corbinc
LQ Newbie
 
Registered: Dec 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
I just added it to the end of the .cshrc file, then i logged out and logged back in and it appears to be running because the dopbox icon is on the system tray (it never showed up there until i ran the command before).

So that seemed to have worked.

Thanks!
 
Old 12-15-2011, 07:07 PM   #7
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 3,222

Rep: Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155
Quote:
Originally Posted by corbinc View Post
I just added it to the end of the .cshrc file, then i logged out and logged back in and it appears to be running because the dopbox icon is on the system tray (it never showed up there until i ran the command before).

So that seemed to have worked.

Thanks!
Careful...the way you have it set up, it's going to be launching dropbox every time you open a terminal. Now if dropbox is clever enough to see that it's already running and cancel the launch, then you're fine, but if not you're going to end up with a LOT of duplicate dropbox sessions after a very short while.
 
Old 12-15-2011, 07:11 PM   #8
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 3,222

Rep: Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155Reputation: 1155
For what it's worth, I have mine set to launch on boot using the cron.

Code:
areynolds@craig:~> crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.rUx0TX installed on Tue Nov 15 19:23:18 2011)
# (Cronie version 4.2)
@reboot $HOME/.dropbox-dist/dropboxd
 
Old 12-15-2011, 07:43 PM   #9
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714
Quote:
Originally Posted by TobiSGD View Post
If you want it to start when the user logs in (which would be a good thing with dropbox) rather than being launched when the machine starts (which would be the case when you put that in rc.local) just add the command to your ~/.bashrc file.
.bashrc is executed whenever you open an interactive terminal, not just when you log in. .bash_profile is run when you log in. I don't know what the csh equivalent of it is, though.

Last edited by MTK358; 12-15-2011 at 07:44 PM.
 
Old 12-15-2011, 11:19 PM   #10
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,653
Blog Entries: 2

Rep: Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097
Quote:
Originally Posted by MTK358 View Post
.bashrc is executed whenever you open an interactive terminal, not just when you log in. .bash_profile is run when you log in. I don't know what the csh equivalent of it is, though.
You are right, I confused that.
 
Old 12-15-2011, 11:51 PM   #11
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
For the tsch shell, look at this from the info file:
Commands like stty(1) and tset(1), which need be run only once per login, usually go in one's ~/.login file.
The ~/.login file is also used for the csh. (In SuSE, the /bin/csh command is a dynamic link to the /bin/tsch command.)

For items when you log in, check for the term "login shell" in the documentation. It is common to set an environment variable in a wrapper. The script should check for this variable and if it doesn't exist, set it and start the service. If it does exist, don't start the service. You might instead check if the dropbox service creates a PID file, and check for that instead. You could have logged into vt2 after being logged in graphically.

Also, for system startup commands, there is a directory /etc/profile.d/ that contain system wide startup scripts for different shells. You could create a dropbox.sh & dropbox.csh script in this directory to start dropbox system wide. This script might for example simple set a variable a user would need. See the /etc/profile.d/cvs.tcsh for an example.
 
Old 12-16-2011, 10:09 AM   #12
corbinc
LQ Newbie
 
Registered: Dec 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
To clarify - I would like the command to run one time, when i log onto a machine (graphical session). I am not root, just a user, so i only need it to start for me.

It does try to start it every time I open a terminal, which isn't ideal even though it does appear to be smart enough to kill one of the sessions. See below:

[1] 11893
daedalus[998]% Another instance of Dropbox (10221) is running!

[1] Exit 255 ~/.dropbox-dist/dropbox
daedalus[998]%

I don't really want to see this every time I open a terminal. So here is whats in my home directory which is all i have access to as a user right? I don't see a .login

Does anyone see the place i should put it? Or will i have access to a .login somewhere outside my home directory?

daedalus[998]% ls -all
total 366
drwxr-xr-x 78 ccarter guest 3072 2011-12-16 07:59 .
drwxr-xr-x 25 root root 512 2011-01-07 15:32 ..
drwx------ 5 ccarter guest 512 2009-07-10 09:28 .adobe
-rw-r--r-- 1 ccarter guest 161 2001-03-20 10:40 .alias
drwx------ 3 ccarter cogall 512 2011-08-04 16:52 .alice
-rw------- 1 ccarter guest 140 2009-07-30 13:37 .appletviewer
drwx------ 2 ccarter cogall 512 2011-08-23 16:15 .arduino
drwx------ 2 ccarter cogall 512 2011-12-15 14:55 bin
drwx------ 10 ccarter guest 512 2011-12-14 08:38 .cache
drwx------ 3 ccarter cogall 512 2011-08-04 11:41 .compiz
drwx------ 23 ccarter guest 1024 2011-12-14 17:03 .config
drwx------ 11 ccarter cogall 512 2011-11-08 17:05 CS273
drwx------ 4 ccarter cogall 512 2011-09-16 10:44 CS371
-rwx------ 1 ccarter guest 1707 2011-12-15 16:59 .cshrc
drwx------ 3 ccarter guest 512 2010-08-31 11:36 .dbus
drwx------ 2 ccarter guest 512 2011-12-14 12:55 Desktop
-rw------- 1 ccarter cogall 28 2011-12-16 07:59 .dmrc
drwxr-xr-x 18 ccarter guest 1024 2011-12-14 16:51 Documents
drwx------ 2 ccarter guest 512 2011-12-15 14:54 Downloads
-rw-r--r-- 1 ccarter cogall 61425 2011-12-14 10:25 Drafts
drwx------ 3 ccarter cogall 512 2011-12-16 08:06 .dropbox
drwx------ 11 ccarter cogall 512 2011-12-16 07:59 Dropbox
drwx------ 4 ccarter cogall 2048 2011-12-05 12:46 .dropbox-dist
drwx------ 4 ccarter cogall 512 2011-12-14 08:44 .eclipse
-rw------- 1 ccarter cogall 641 2011-12-14 10:50 .emacs
drwx------ 3 ccarter cogall 512 2011-12-14 10:50 .emacs.d
-rw------- 1 ccarter guest 16 2009-07-08 09:43 .esd_auth
drwx------ 7 ccarter cogall 512 2011-12-09 11:26 .evolution
drwx------ 2 ccarter guest 1536 2011-12-14 09:52 .fontconfig
drwx------ 5 ccarter guest 512 2011-12-16 07:59 .gconf
drwx------ 2 ccarter guest 512 2011-12-16 08:06 .gconfd
drwx------ 12 ccarter guest 512 2011-12-15 17:03 .gnome2
drwx------ 2 ccarter guest 512 2009-07-08 09:43 .gnome2_private
drwxr-xr-x 2 ccarter guest 512 2011-12-15 17:00 .gstreamer-0.10
-rw------- 1 ccarter cogall 177 2011-12-16 07:59 .gtk-bookmarks
drwx------ 2 ccarter guest 512 2009-07-08 09:43 .gvfs
-rw------- 1 ccarter guest 321 2009-07-08 10:21 Hello.java~
-rw------- 1 ccarter guest 22420 2011-12-16 08:06 .history
drwxr----- 2 ccarter guest 512 2010-08-31 11:36 .hplip
-rw------- 1 ccarter guest 69225 2011-12-16 07:59 .ICEauthority
drwx------ 5 ccarter cogall 512 2011-08-22 10:32 .icedtea
drwx------ 3 ccarter guest 512 2010-09-07 12:14 .icedteaplugin
drwx------ 2 ccarter guest 512 2010-08-31 11:44 .icons
drwx------ 7 ccarter cogall 512 2011-09-16 09:24 .imap
drwx------ 4 ccarter cogall 512 2011-12-13 16:50 .java
-rw------- 1 ccarter cogall 439 2011-08-15 09:24 .joe_state
drwx------ 3 ccarter guest 2048 2011-12-14 12:22 .kde-suse
drwx------ 3 ccarter cogall 512 2011-08-02 14:36 .libreoffice
drwx------ 3 ccarter guest 512 2009-07-08 09:43 .local
drwx------ 3 ccarter cogall 512 2011-12-14 09:04 .m2
drwx------ 3 ccarter guest 512 2009-07-10 09:28 .macromedia
drwx------ 3 ccarter cogall 512 2011-12-15 15:40 mail
-rw-r--r-- 1 ccarter cogall 60 2011-09-16 09:24 .mailboxlist
-rwx------ 1 ccarter guest 62 1995-12-12 16:38 .mailrc
drwx------ 2 ccarter cogall 512 2011-08-09 16:27 .mc
drwx------ 3 ccarter guest 512 2009-07-08 10:09 .mcop
-rw------- 1 ccarter guest 31 2009-08-05 13:46 .mcoprc
drwx------ 3 ccarter guest 512 2009-07-08 09:43 .metacity
drwx------ 3 ccarter cogall 512 2011-12-09 11:26 .mission-control
drwx------ 5 ccarter guest 512 2011-09-07 11:05 .mozilla
drwx------ 2 ccarter guest 512 2010-08-31 11:36 Music
drwx------ 2 ccarter cogall 512 2011-12-09 12:17 .nautilus
drwx------ 3 ccarter cogall 512 2011-12-13 16:50 .netbeans
drwx------ 6 ccarter cogall 512 2011-12-14 10:45 NetBeansProjects
drwx------ 3 ccarter guest 512 2010-08-31 11:38 .netx
-rwx------ 1 ccarter guest 0 2001-03-20 10:47 .newsrc
drwx------ 3 ccarter cogall 512 2011-12-09 11:57 .nv
drwx------ 3 ccarter guest 512 2011-08-02 14:37 .ooo-2.0
drwx------ 2 ccarter guest 512 2011-12-14 10:02 Pictures
drwx------ 2 ccarter guest 512 2010-08-31 11:36 Public
drwxr-xr-x 2 ccarter cogall 512 2011-11-22 10:45 public_html
drwx------ 2 ccarter cogall 19968 2011-12-14 12:22 .pulse
-rw------- 1 ccarter guest 256 2009-07-08 09:43 .pulse-cookie
drwx------ 2 ccarter guest 512 2009-07-08 10:02 .qt
drwx------ 3 ccarter cogall 512 2011-08-04 10:00 .rcc
-rw------- 1 ccarter guest 1958 2009-02-09 10:00 README
-rw------- 1 ccarter guest 532 2009-07-28 13:20 .recently-used
-rw------- 1 ccarter cogall 24505 2011-12-15 17:03 .recently-used.xbel
drwx------ 2 ccarter guest 512 2009-07-08 09:43 .skel
drwx------ 2 ccarter cogall 512 2011-08-23 16:15 sketchbook
drwx------ 2 ccarter cogall 512 2011-12-15 15:35 .spamassassin
drwx------ 2 ccarter cogall 512 2011-08-04 10:44 .ssh
drwx------ 3 ccarter cogall 512 2011-08-18 16:29 .subversion
drwx------ 3 ccarter cogall 512 2011-12-09 11:59 .swt
drwx------ 2 ccarter guest 512 2010-08-31 11:36 Templates
drwx------ 5 ccarter cogall 512 2011-12-14 09:00 test2
-rw------- 1 ccarter cogall 95 2011-12-09 12:00 Test.java
drwx------ 3 ccarter guest 512 2011-08-26 11:14 .themes
drwx------ 4 ccarter guest 512 2011-08-02 13:56 .thumbnails
drwx------ 4 ccarter cogall 512 2011-12-14 09:53 .thunderbird
drwx------ 4 ccarter guest 512 2010-08-31 11:36 .tomboy
-rw------- 1 ccarter guest 4744 2009-08-06 15:44 .tomboy.log
drwx------ 2 ccarter guest 512 2010-08-31 11:36 Videos
-rw------- 1 ccarter guest 4184 2011-12-15 16:43 .viminfo
drwx------ 2 ccarter guest 512 2009-08-06 15:44 .wapi
-rw------- 1 ccarter cogall 115 2011-12-14 10:17 webct_upload_applet.properties
drwx------ 6 ccarter cogall 512 2011-12-09 11:55 workspace
drwx------ 4 ccarter cogall 512 2011-12-09 12:03 workspace2
drwx------ 4 ccarter cogall 512 2011-12-09 11:59 workspace3
drwx------ 4 ccarter cogall 512 2011-12-09 12:01 workspace4
drwx------ 4 ccarter cogall 512 2011-12-13 16:58 workspaceR
-rw------- 1 ccarter cogall 420 2011-12-16 07:59 .Xauthority
drwx------ 2 ccarter guest 512 2010-08-31 12:01 .xine
-rw------- 1 ccarter cogall 27138 2011-09-15 17:02 .xsession-error
-rw-r--r-- 1 ccarter cogall 24979 2011-12-16 08:07 .xsession-errors
-rw------- 1 ccarter cogall 7361 2011-08-19 15:31 .xsession-errors.old
daedalus[999]%

Last edited by corbinc; 12-16-2011 at 10:24 AM.
 
Old 12-17-2011, 05:40 AM   #13
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
Put your script in ~/.local. You should have indicated which shell you are using up front in the first post.

A login shell is a shell that starts when you login. In bash, it sources .profile. In csh it sources .local

The ~/.local file is in your directory listing. If it doesn't exist, then create a new one.

Last edited by jschiwal; 12-17-2011 at 05:46 AM.
 
Old 12-19-2011, 10:22 AM   #14
corbinc
LQ Newbie
 
Registered: Dec 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Okay, where exactly do I put the command? Do I need to create a new directory?

I see the .local, in that directory there is a "share" directory and within share i have all of these directories:
ls -all
total 86
drwx------ 16 ccarter guest 512 2011-12-16 17:00 .
drwx------ 3 ccarter guest 512 2011-12-19 08:18 ..
drwx------ 2 ccarter cogall 512 2011-12-16 08:16 applications
-rw------- 1 ccarter guest 0 2010-08-31 11:36 .converted-launchers
drwx------ 2 ccarter cogall 512 2011-08-02 16:55 desktop-directories
drwx------ 6 ccarter cogall 512 2011-12-09 11:26 evolution
drwx------ 2 ccarter cogall 512 2011-12-09 11:26 folks
drwx------ 4 ccarter guest 512 2011-12-14 12:22 gnome-do
drwx------ 2 ccarter guest 512 2010-08-31 11:36 gnome-main-menu
drwx------ 3 ccarter cogall 512 2011-12-16 16:59 gnome-shell
-rw------- 1 ccarter cogall 731 2011-12-09 11:25 gsettings-data-convert
drwx------ 2 ccarter guest 1536 2011-12-19 08:20 gvfs-metadata
drwx------ 2 ccarter guest 512 2011-12-15 15:14 parcellite
-rw------- 1 ccarter cogall 68973 2011-12-16 17:00 recently-used.xbel
drwx------ 3 ccarter cogall 512 2011-12-09 11:26 telepathy
drwx------ 2 ccarter guest 512 2010-08-31 11:36 tomboy
drwx------ 3 ccarter guest 512 2011-12-19 08:16 tracker
drwx------ 5 ccarter guest 512 2011-08-02 16:54 Trash
drwx------ 3 ccarter cogall 512 2011-08-22 10:24 webkit


pwd
/home/nacs1/ccarter/.local/share
 
Old 01-03-2012, 03:04 AM   #15
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,689

Rep: Reputation: Disabled
KDE has an autostart functionality too. I'm sitting in front of a windows box, so I can't look for it now, but I seem to remember that you can reach it via the control center.
 
  


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
[SOLVED] run command/program after failed login attempts xwjitftu Linux - Security 7 08-26-2011 07:23 PM
Auto run and only run a program after login? narke Slackware 2 05-27-2011 01:51 PM
How to enter graphical mode (run level 5) command line (run lenel 3) edmondgyampoh Linux - Newbie 3 05-15-2009 07:33 PM
[SOLVED] Getting a command to run on ssh/cli login ONLY Vanyel Linux - Software 4 03-03-2008 10:38 AM
run command at boot/login? apberzerk Linux - General 1 09-22-2003 11:25 PM


All times are GMT -5. The time now is 04:02 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration