I have just installed NS2 on Mac OS X Mavericks (10.9)
I have set all the paths correctly.
I can successfully type 'ns' on the terminal, and 'nam' as well, and both execute without any problem.
The problem is that when I input a file to the ns command, it says:
couldn't read file "example.tcl": no such file or directory
I use this command in the terminal:
ns example.tcl
I also tried it running it in sudo mode:
sudo -s
ns example.tcl
I placed the file in the bin folder, where there's ns's shortcut, I also placed it where actually the ns is. I also tried giving it a full path to the tcl file, but no use in both the cases.
I also tried to run it after executing only ns first, and then within ns ran it (No idea if it works like this, I am just trying everything I have got!)
ns
%ns example.tcl (Hash sign shows the NS is running and I am typing the command there)
This time the error is:
warning: using backward compatibility mode
error when calling class OldSim: hello-ddos.tcl
The version of NS is 2.35.
NOTE: I changed the file extension from .tcl to .txt, and it works fine now. Any idea of the problem?
Please help!
The error message:
couldn't read file "example.tcl": no such file or directory
is pretty clear. It simply couldn't find the file; the OS returned an ENOENT error from the underlying system call to open the file. The usual reason for this is that the file isn't in the directory that you're running the program from, and the usual recommendation for dealing with this is to use the full name of the file instead of just the local path-less version. (It's technically possible for there to be other issues, but they usually produce different errors.)
What can cause this? Well, one of the most common things is if you (or some library code, such as what is inside NS2) does a cd to change the current directory. Using a full, absolute filename makes (or at least should make) your code much more resistant to that sort of thing.
Warning: note that the second part of your question relating to changing the filename is strange to me.
Check the directory of your file. It should be in the bin folder inside your ns folder.
Also you may try typing
sudo ./ns filename.tcl
to give you root access if by any chance you are detached from that.
Related
I am trying to run one of the example from Beej's Guide to Network Programming (https://beej.us/guide/bgnet/), specifically showip.c (The link to the program is here: https://beej.us/guide/bgnet/examples/showip.c). Using gcc, I've typed in
gcc -o showip showip.c
Then ran the program
showip www.example.net
and I get an error showip: command not found on the same directory where the code and the program is compiled at. I'm not sure why this is the case. I've even cloned the code from his GitHub and used makefile to compile the program and yet I'm getting the same error. What exactly am I doing it wrong here?
This is actually problem with how you're running the program.
On Linux systems (unlike Windows systems) an executable in the current directory is not by default searched by the shell for programs to run. If the given program does not contain a path element (i.e. there are no / characters in the name) then only the directories listed in the PATH environment variable are searched.
Since the current directory is not part of your PATH, prefix the command with the directory:
./showip www.example.net
Is the working directory on your path? Likely not.
Try ./showip
Since the program showip is not in your $PATH you have to tell
your shell that it's in the current directory:
./showip
Or add the current directory to your $PATH but it's a less secure
option:
PATH=:$PATH
or
PATH=.:$PATH
and run it as you're trying now:
showip
I am trying to use a simple bash script that uses a script in /opt
#!/bin/bash
pvpython=/opt/paraviewopenfoam54/bin/pvbatch
script_path=save_contours.py
$pvpython $script_path
The file pvbatch does exist, however when I try to run the script I get this strange error message which feels like it is missing some characters:
: No such file or directoryaviewopenfoam54/bin/pvbatch
The Ubuntu I am using is Ubuntu 18.04.1 LTS inside a Windows subsystem for Linux. What could cause this error message?
When I run ls -al pvbatch in /opt/paraviewopenfoam54/bin I get
-rwxr-xr-x 1 root root 84200 May 29 2018 pvbatch
cat pvbatch returns an error message
cat: write error: Input/output error
So cat cant read the file which is strange!
My first thought is that there is an issue with the file itself. where was the file created? I see that it is under /opt/paraviewopenfoam54/bin which is a linux managed folder, did you create and edit the file using vim in WSL or did you create it in windows somehow with VS Code or the like?
Let me just check that you are not creating and editing files in windows directly in the /opt folder inside the %LOCALAPPDATA% folders. If the file was created in this method you risk corrupting the WSL installation. Dont Edit WSL files
When using WSL I commonly find issues and especially this Input/output error issue whenever I create a file directly from windows into the Linux filesystem. There are essentially three main ways to fix this specific issue: (these are not steps but rather separate solutions)
-Restart your Ubuntu terminal
-Restart your entire computer
-Delete the file directly from Windows, touch the file, then overwrite the file with the old one
For a more scalable solution, I recommend leaving the file within the windows system and only working within the Linux system within Linux.
I am trying to execute a Makefile script and my Mac complains about 7zcat, although I already have 7z installed.
/bin/sh: 7zcat: command not found
Any thoughts on what's missing on my system? Thank you!
I have never used 7zcat before.
However, it looks like it needs to be installed on your system.
https://github.com/essentialkaos/7zcat
Also, after you download install 7zcat you have to give it execute permission with chmod. Finally, you have to execute it by calling its full path for example if you installed it to the directory you are in you would run ./7zcat file.7z or you would add the path to the file to your environment's $PATH variable.
I hope this helps. You might have to do some more research though.
When you open a Terminal window and type 7zcat and hit enter, what happens? Same message? Well, if you cannot use it, why should make be able to use it? Where and how have you installed 7z? Is the folder with the 7z binaries in your PATH? Since if it isn't, of course the command won't be found.
When the system shall run a command, it will search for this command in the directories stored in the PATH variable. Execute echo $PATH in terminal and you will get a colon separated list of directories; only these directories are searched for binaries. So either you must move your binaries to one of these (or put a symlink to one of these) or add the directory with these binaries to the PATH.
Yet there is no official 7z command line installer for MacOS, which brings me back to the original questions "Where and how have you installed 7z?" And are you sure that whatever you installed even includes a 7zcat?
First of all, I would like to apologize if I'm on the wrong stackexchange network, and secondly, sorry if I'm overlooking something simple.
I was moving files from my old hard drive from an old PC when I came across several password protected ZIP Files. However, since those files were a bit old, I forgot the passwords already. I tried every password I could come up with but I still came up empty. After several google searches, I found this tool/utility for Mac OS X that could help me. So I go to the downloads page and download the Mac OSX utility tool and the source code.
However, I am having problems executing the make command for the file. It says on the downloads page:
If you are using linux or another unix, you need to download the source code, uncompress it and type "make" to compile the utility.
So far, what I've tried is
$make /Users/myname/Downloads/aapr-0.01-source/Makefile
I have also tried the other files in the source folder but nothing worked. After that, I'm pretty much blank. I tried double clicking the aapr file in the utility download for Mac (which is a Unix Executable) and it opens a new terminal window displaying the commands and such. Also, doing $aapr [options] [filename] only shows me -bash: aapr: command not found. I also updated XCodes command line tools.
Sorry if I'm missing out on something very basic, I don't usually use the terminal on the OS X.
Try running
cd /Users/myname/Downloads/aapr-0.01-source
make
A Makefile contains rules for building files from other files but it is based on paths and contents, etc. which depend on your current location. So generally you need to be in the directory of the project for it to work.
Edit (copied from my comment):
To execute a command from a specific location (that isn't in the normal $PATH) you need to specify a path for it. So something like /bin/bash or ./aapr (where ./ means the current directory).
I used addpath(pwd) to get my .m files working in my projects directory. When I close the window and start a new window, the path I just added is gone. But the files still run.
Is it in my path or not? How do I see the directories I have added to my path?
Also, . is the first entry I see from path. Does that mean I don't need to add any directories because it will always search the current directory first?
Thanks.
Basically, yes.
You can add a directory to the search path using addpath(), but as you know, it only exists for the current session and is reset when you restart Octave. If you want a path to survive between sessions, add it to your octaverc, a script file that gets run whenever a new session gets started. Example path to octaverc file is:
C:\Octave\3.2.4_gcc-4.4.0\share\octave\site\m\startup
Since . is in your path by default, Octave will search your current directory for any function files that it needs. Using addpath(pwd) is somewhat useless if you're just going to stay in the same directory. However, there are some cases where it'd be useful, if for example you have a directory that contains your functions, and another one that has the data that you're working on: you could start in the functions directory, do addpath(pwd), and then cd to the data directory while still being able to use your functions.
You can create batch file, which will start Octave with your directory path. Please see example below:
octave-3.6.4.exe -p "C:\MyOctaveDiretory"
-p means addpath()
addpath(pwd); savepath();
Done.
I think there is a bug in Octave (I use version 4.0.3 on Windows). When I create a new file in current path, this can't be called by Octave ("error: 'foo' undefined near line 1 column 1"). If I restart Octave, it works. This addpath(pwd) trick helps me a lot (before I unsuccessfully tried rehash() and cd elsewhere and back again).
If you had the same problem, the reason for the symptom might be:
Start Octave.
Create newfile.m.
Call newfile - fails since Octave did not register its existence.
addpath(pwd) - causes Octave to register it.
Close Octave
Start Octave - now pwd is gone from path, but newfile.m is registered at startup.
call newfile - works
I faced a similar problem in adding path where the path was added by using addpath command directly in Octave GUI (Command Window). The path added was being shown in console window but none of the functions worked.
The problem was solved by changing the path directory from Windows directory to some other direction where OS is not installed.