2

Say I have an /etc/profile

# good stuff here
# ...

/usr/local/bin/obnoxious_ascii_art

Is there anything I can do to prevent the execution of the last line when I log in? Assume I don't necessarily have root access.

  • Is this a machine you're accessing via SSH? If so there might be some dirty stuff you can do with an authorized_keys command. But otherwise, I don't think so. /etc/profile is executed before any of your personal files, thus you don't get a chance to do anything about it. – Patrick May 28 '14 at 19:10
  • 2
    No! ~\O?\O/O/~ ...[]:} – goldilocks May 28 '14 at 19:11
  • @Patrick Yes, via SSH. Interesting thought about the authorized_keys command. – cpugeniusmv May 28 '14 at 19:16
  • 1
    If all else fails, you could change your shell to csh and then exec your regular shell in your ~/.login – Mark Plotnick May 28 '14 at 21:46
  • 1
    Sacrilege ;) But one day you might return the favor! – user44370 May 28 '14 at 22:38
2

If I can't prevent it, I can at least hide the output after the fact with this in my .bash_profile:

clear

Or, if I know how many lines it is:

for l in {1..26}; do
  tput cuu1 # move up a line
done
tput ed # clear to end of screen
  • 1
    Even if you don't know how many lines it is, or if it can change, you can run it again manually and pipe it into wc -l – Patrick May 28 '14 at 19:35
1

You can copy profile to your home, edit it as needed
after that, this should work

ssh -t user@host '. ~/profile ; bash'

-t Force pseudo-tty allocation

1

It depends on what do you mean by "obnoxious_ascii_art".

If it's admin's practical joke, you should simply talk to the guy with root access about it. In this case it's a social problem and you should solve it by social means, not with technology.

If it's something that actually does something, but you don't like it, try to ask yourself why it's there in the first place. Maybe it's security related? In such case - I'm sorry to say that, but just let it run - when the machine goes belly up, nobody will blame you.

If it's something broken (but the admin refuses to fix it, for any reason), or you're just curious, then Mark Plotnick's comment is the best solution I can think of.

I know it's not the kind of answer you expected, but technical brute forcing through the problem is not always the best way.

  • In this case it's exactly what it sounds like :) I probably need to encourage him to add a [ -e ~/.ascii_art_is_stupid ] check to his script. I was merely curious (from a purely technical standpoint) to see if there were some obscure or interesting workarounds. – cpugeniusmv May 28 '14 at 22:10
  • Or to check UID. But your idea is better, because any user may configure it. Hell, he can even make a feature, so that any user may configure which ascii art he gets (in your case - empty file). That may convince him, because probably he will snatch the credit and bragging rights for new feature. – Darth Hunterix May 28 '14 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.