LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-24-2007, 06:17 AM   #1
amivit
LQ Newbie
 
Registered: Aug 2007
Distribution: openSUSE 10.2
Posts: 12

Rep: Reputation: 0
Question Script After Login


I am extremely confused. I have tried alot of different things and have gotten close a few times, but still no luck.
Normally I have to manually type this after I login. (I only have root acc)
Code:
modprobe ndiswrapper
macchanger -m=00:1a:73:65:76:a0 wlan0
But I want this to happen automatically. Now would someone please explain/guide me how to do this.
And please remember it has to be executed AFTER I get past the login screen where I type root + password or else it wont work.
Thank you very much!
 
Old 10-24-2007, 06:26 AM   #2
Dinithion
Member
 
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
Well, the ~/.profile runs when you login with tty. You could try to add them there.
 
Old 10-24-2007, 07:06 AM   #3
amivit
LQ Newbie
 
Registered: Aug 2007
Distribution: openSUSE 10.2
Posts: 12

Original Poster
Rep: Reputation: 0
Thank you very much! Now how do I add the probe and macchange commands to:
(Please guide me :b)
Code:
# /etc/profile: This file contains system-wide defaults used by
# all Bourne (and related) shells.

# Set the values for some environment variables:
export MINICOM="-c on"
export MANPATH=/usr/local/man:/usr/man:/usr/X11R6/man
export HOSTNAME="`cat /etc/HOSTNAME`"
export LESSOPEN="|lesspipe.sh %s"
export LESS="-M"

# If the user doesn't have a .inputrc, use the one in /etc.
if [ ! -r "$HOME/.inputrc" ]; then
  export INPUTRC=/etc/inputrc
fi

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/local/apache/bin:/usr/local/pgsql/bin:/opt/mono/bin:/usr/local/pgsql/bin:/opt/nessus/bin:."

# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH.  Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
  fi
fi

# I had problems using 'eval tset' instead of 'TERM=', but you might want to 
# try it anyway. I think with the right /etc/termcap it would work great.
# eval `tset -sQ "$TERM"`
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux
fi

# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
  VISUAL=emacs
#  VISUAL=gmacs
#  VISUAL=vi
fi

# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
if [ "$SHELL" = "/bin/pdksh" ]; then
 PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
 PS1='! ${PWD/#$HOME/~}$ '
elif [ "$SHELL" = "/bin/zsh" ]; then
 PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
 PS1='$ '
else
#My colour additions (muts)

#PS1="\u@\h:\w\$ "
#PS1="\[\033[1;34m\]\u@\h:\w\$ \033[0m "
#PS1='\[\e[34;1m\]\u@\h:\w\$ \[\e[0m\]'
PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]'
fi
PS2='> '
export PATH DISPLAY LESS TERM PS1 PS2

# Default umask.  A umask of 022 prevents new files from being created group
# and world writable.
umask 022

# Set up the LS_COLORS and LS_OPTIONS environment variables for color ls:
if [ "$SHELL" = "/bin/zsh" ]; then
 eval `dircolors -z`
elif [ "$SHELL" = "/bin/ash" ]; then
 eval `dircolors -s`
else
 eval `dircolors -b`
fi

# Notify user of incoming mail.  This can be overridden in the user's
# local startup file (~/.bash.login or whatever, depending on the shell)
if [ -x /usr/bin/biff ]; then
 biff y
fi

# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done
unset profile_script

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
 PATH="$PATH:."
fi

Last edited by amivit; 10-24-2007 at 07:13 AM.
 
Old 10-24-2007, 07:43 AM   #4
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
You may be better off putting those commands in your rc.local file (usually in /etc/init.d/ or /etc/rc.d/ or /etc/rc.d/init.d), so that they get run at every boot.

The .profile file is a script that runs each time you log in; rc.local runs each time the machine boots up, just before the login prompt.

In either case, the script is written in a shell programming language (usually bash), which is basically the same as the language you use to type in to your text console. So you should be able to add these lines to the end of the file.

You can either do this with a text editor, or from the shell:

Code:
echo 'modprobe ndiswrapper' >> ~/.profile
echo 'macchanger -m=00:1a:73:65:76:a0 wlan0' >> ~/.profile
 
Old 10-24-2007, 07:48 AM   #5
amivit
LQ Newbie
 
Registered: Aug 2007
Distribution: openSUSE 10.2
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by amivit View Post
And please remember it has to be executed AFTER I get past the login screen where I type root + password or else it wont work.
I tried doing that, the modprobe ndiswrapper worked perfectly but the macchange did not. The macchange has to be executed somehow after login.
Any ideas?
 
Old 10-24-2007, 07:50 AM   #6
Dinithion
Member
 
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
Have you tried using the full path of the macchanger program (I.e. /usr/sbin/macchanger ...)?
 
Old 10-24-2007, 08:02 AM   #7
amivit
LQ Newbie
 
Registered: Aug 2007
Distribution: openSUSE 10.2
Posts: 12

Original Poster
Rep: Reputation: 0
Cool

Quote:
Originally Posted by Dinithion View Post
Have you tried using the full path of the macchanger program (I.e. /usr/sbin/macchanger ...)?
There we go ! Now it works perfectly . One last thing, I can now see the output of macchanger at the top of my login screen. Anyway to make it invisible so macchanger does its job in the background?
 
Old 10-25-2007, 09:20 AM   #8
amivit
LQ Newbie
 
Registered: Aug 2007
Distribution: openSUSE 10.2
Posts: 12

Original Poster
Rep: Reputation: 0
little bumper, I added a few other commands to the rc.d file and now I got a pretty long output on my login screen and it is pretty annoying. So how do I make these scripts run in background?
 
Old 10-25-2007, 10:16 AM   #9
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
You're talking about two very different things here. To background a process, you add an '&' after the command, this effectively 'daemon'-izes the process, but it will still dump all output to the screen 'stdout'. I don't think this is what you were talking about, was it ? What you might want is to redirect output to something other than 'stdout'. To do this you can add either '1> file' for redirecting stdout, '2> file' for stderr (errors) or ' 1> file 2>&1' for both after the command, where 'file' can be any file including '/dev/null' the 'black hole'

Examples:
Code:
# background a process
command &
# redirect program stdout output to 'file'
command 1> file
# redirect program stderr output to 'file'
command 2> file
# redirect all program output to 'file'
command 1> file 2>&1
Also note:
0 = stdin
1 = stdout
2 = stderr

And remember, try not to use terms you don't fully understand, just describe what you want to do.

Last edited by H_TeXMeX_H; 10-25-2007 at 10:21 AM.
 
Old 10-26-2007, 06:05 AM   #10
amivit
LQ Newbie
 
Registered: Aug 2007
Distribution: openSUSE 10.2
Posts: 12

Original Poster
Rep: Reputation: 0
Oh yeah, I formulated myself incorrect there. Making a script run in
background could be understood that it is running all the time. Well what
I meant was just the output had to be invisible. Well despite that, you
gave me the answer I needed - so thank you very much
 
  


Reply



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 check in a script whether the shell is login or non login? frankie_DJ Programming 7 10-21-2015 10:09 AM
Need a login script stefaandk Linux - Newbie 4 01-05-2006 04:24 PM
Login script unclejessie77 Programming 5 02-24-2005 12:30 PM
Login Script meenalborkar Red Hat 1 02-18-2005 05:37 AM
login-script thermite_1033 Linux - Security 2 09-28-2004 04:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:59 PM.

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