1

invalid command name "gcc" while executing "gcc rsa.c -o rsa -lm" (file "./run.sh" line 1)

does gcc-4.9.2 works correctly on ns-2.35 or is it gcc-4.4

earthmeLon
  • 11,042
  • 1
  • 36
  • 60
Rakend Raj
  • 11
  • 3
  • What's the CLI output of `which gcc`? – earthmeLon Oct 11 '15 at 18:46
  • gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) this is the version of gcc i'm using.. – Rakend Raj Oct 11 '15 at 18:47
  • Any way we can take a look at the contents of `run.sh`? – earthmeLon Oct 11 '15 at 18:48
  • gcc rsa.c -o rsa -lm ./rsa ns main.tcl – Rakend Raj Oct 11 '15 at 18:49
  • I'm glad to know your version of gcc, but what's the output of `which gcc`. What happens when you place `which gcc` at the top of your script and try to run it. It should have output. – earthmeLon Oct 11 '15 at 18:53
  • invalid command name "gcc" while executing "gcc rsa.c -o rsa -lm" (file "./run.sh" line 1) this is the output of gcc-4.8.4 which i'm using now – Rakend Raj Oct 11 '15 at 18:55
  • gcc-4: /usr/bin/gcc-4.8 /usr/bin/gcc-4.6 /usr/bin/gcc-4.9 /usr/bin/gcc-4.4 /usr/bin/X11/gcc-4.8 /usr/bin/X11/gcc-4.6 /usr/bin/X11/gcc-4.9 /usr/bin/X11/gcc-4.4 these are the versions of gcc in my system and i'm running gcc-4.8 – Rakend Raj Oct 11 '15 at 19:00
  • invalid command name "gcc" while executing "gcc rsa.c -o rsa -lm" (file "./run.sh" line 1) my question is i have installed gcc but why am i getting this error as invalid command...?? – Rakend Raj Oct 11 '15 at 19:02
  • Yeah, but I'm asking you to change your file to look like this: http://pastie.org/private/gustqjww03d5tplyigznmw . I want to see the actual output of these commands, not your interpretation of my question. – earthmeLon Oct 11 '15 at 19:04
  • invalid command name "which" while executing "which gcc" (file "./run.sh" line 1) – Rakend Raj Oct 11 '15 at 19:07
  • So, it looks like your Environmental Variables are messed up. You're missing things, such as `$PATH`, most likely. Maybe it's as simple as placing `#!/bin/bash` at the top of your script, but it seems like you have bigger problems than that. What shell is it using? `echo $0` should tell you if it's `sh` or `bash` or what. – earthmeLon Oct 11 '15 at 19:09
  • yes u r right ... pls help me to set a proper path may be i wish to put gcc-4.4 as default – Rakend Raj Oct 11 '15 at 19:11
  • Have you tried opening a new terminal? That one might have gotten messed up in some way. Can the terminal you're in run *any* commands? What happens if you run `which gcc` in the terminal, not in the script? Does it actually give you good output? – earthmeLon Oct 11 '15 at 19:11
  • Your issue is *NOT* gcc right now. If `which` won't work, most likely nothing will work. We need to get your shell working by determining which shell you're using and why your Environmental Variables aren't loading. – earthmeLon Oct 11 '15 at 19:12
  • /usr/bin/gcc this is what i am getting on running the command "which gcc" – Rakend Raj Oct 11 '15 at 19:14
  • Okay, so the issue here is that whatever is running your script is not loading up your environmental variables. I'm not really sure the solution. What happens when you add `#!/bin/bash` to the top of the script? Does that help at all? – earthmeLon Oct 11 '15 at 19:16
  • no i'm gettintg the same thing when i add the above thing.. – Rakend Raj Oct 11 '15 at 19:18
  • http://pastie.org/private/4eo8td8hv6hedgv1f4wwq – earthmeLon Oct 11 '15 at 19:19
  • Is it `bash run.sh` vs `./run.sh` that's making it work? – earthmeLon Oct 11 '15 at 19:26
  • i really appreciate ur time and dedication ..#earthmeLon thanks again .. – Rakend Raj Oct 11 '15 at 19:27
  • #!/bin/bash echo $0 echo $PATH which gcc gcc rsa.c -o rsa -lm ./rsa ns main.tcl i mean bash run.sh – Rakend Raj Oct 11 '15 at 19:28
  • "*invalid command name*" sounds more like a `tcl` error than a bash one: are you **sure** you are executing this command in a bash shell? – steeldriver Oct 11 '15 at 20:32

1 Answers1

1

Instead of running the script as ./run.sh, be sure that the first line of the script is #!/bin/bash and run it with bash run.sh.

earthmeLon
  • 11,042
  • 1
  • 36
  • 60