0

Before I start, I just wanna say I've looked for over an hour for an answer but can't find anything.

Basically I use Ubuntu through VirtualBox which works fine. I installed NetKit because that's what I'm using in Uni and it also works fine, however, everytime I restart Ubuntu, I have to keep entering these 3 commands in order to make NetKit work again (idk why), so I thought I'd make a script to automatically do this everytime I start up Ubuntu.

I know it opens a sub-shell to run the commands and then closes itself, which is why it doesn't work. I was just hoping someone could tell me a workaround for this and make it run in the main terminal:

#!/bin/bash
#Set the Netkit home

export NETKIT_HOME=/home/yusuf/Desktop/NetKit/netkit

export MANPATH=:$NETKIT_HOME/man

export PATH=$NETKIT_HOME/bin:$PATH

I tried adding . netkit_start.sh but it just has an error which says Segmentation fault (core dumped)

Thanks for the help

  • Have you considered putting these contents in your `.bash_profile` rather than a separate script? – Charles Duffy Oct 10 '17 at 21:48
  • BTW, do *read* the linked questions -- neither is just "you can't do it"; each describes an adequate workaround. – Charles Duffy Oct 10 '17 at 21:50
  • (btw, a segfault when sourcing a file is really a very separate problem, which we'd want to investigate separately; generally speaking, any time the shell segfaults, you've triggered a bug in the shell -- and they're generally a lot harder to find than this. I wonder if maybe your file is saved in an unusual format like UTF-16? That can happen if you created it on Windows). – Charles Duffy Oct 10 '17 at 21:52
  • ...consider `(set -x; . netkit_start.sh)` to log commands as the shell runs them, so we can get a better idea of exactly where that segfault is happening. But here, as in general, a segfault is more something to report to the software's vendor or your OS vendor than something you've done wrong. – Charles Duffy Oct 10 '17 at 21:53
  • @CharlesDuffy I just get +++++++++++ . netkit_start.sh ++++++++++++++++++++++++++++++++++++++++ set -x (And then it just repeats forever.. CTRL+C doesn't stop it – ThatOneGuy1 Oct 10 '17 at 21:59
  • "Repeats forever"? That sounds like it's recursing, if at least it's repeating the `. netkit_start.sh` part. Shouldn't happen with the exact code you gave here without any traps being set, but then, since you're running a shell with unknown/indeterminate configuration, for all I know there *are* traps set. Or maybe you have something in your real code (not given in your question here) that *does* cause it to recurse. – Charles Duffy Oct 10 '17 at 22:03
  • If you set `PS4=':${BASH_SOURCE##*/}:${LINENO}+'` first, how does that output change? (If you need to paste it somewhere else to preserve newlines, consider https://gist.github.com/). – Charles Duffy Oct 10 '17 at 22:04
  • @CharlesDuffy Do you know any way I can run those 3 commands in a shell automatically? Or can you point me to a tutorial? – ThatOneGuy1 Oct 10 '17 at 22:05
  • I already told you, in the very first comment on this question -- put them in your `.bash_profile`. – Charles Duffy Oct 10 '17 at 22:05
  • @CharlesDuffy Oh.. How do I do that? Do I do echo 'Command' >>~/.bash_profile ? That's what I saw online – ThatOneGuy1 Oct 10 '17 at 22:11
  • Also, Adding PS4=':${BASH_SOURCE##*/}:${LINENO}+' does nothing to the script. Just for clarification, I am using Ubuntu on VirtualBox on windows 10 – ThatOneGuy1 Oct 10 '17 at 22:11
  • I'm not telling you to add that to the script, I'm telling you to run it on the same command line *before* the script. That is: `( PS4=':${BASH_SOURCE##*/}:${LINENO}+'; set -x; . netkit_start.sh )` -- that will amend the logs from `set -x` to show which line of which file is being executed at any given time. The intent is that you then show me those logs -- at minimum two loops' worth -- somewhere (not a StackOverflow comment!) that will preserve newlines. – Charles Duffy Oct 10 '17 at 22:26
  • And I don't much recommend `echo "..." >>.bash_profile` -- better to use a real editor. `vim` and `emacs` are the ones that'll get you street cred, but if it's easier to use `nano`, just don't admit having done so in public after. :) – Charles Duffy Oct 10 '17 at 22:28
  • Actually -- if you aren't familiar with any editors, how did you create `netkit_start.sh` in the first place? If you created it with Windows-native tools (and weren't capable about what format it's saved in), that might go some distance towards explaining why things aren't working. – Charles Duffy Oct 10 '17 at 22:37

0 Answers0