Actually I'm trying to generate .h & .c files by given sysSwYear as MIBNODE and I'm using following command:
mib2c -c mib2c.scalar.conf sysSwYear
but it produces the following error:
You didn't give mib2c a valid OID to start with. IE, I could not find
any information about the mib node "sysSwYear.0". This could be caused
because you supplied an incorrectly node, or by the MIB that you're
trying to generate code from isn't loaded. To make sure your mib is
loaded, run mib2c using this as an example:
env MIBS="+MY-PERSONAL-MIB" mib2c -c mib2c.scalar.conf sysSwYear.0
You might wish to start by reading the MIB loading tutorial at:
http://www.net-snmp.org/tutorial-5/commands/mib-options.html
And making sure you can get snmptranslate to display information about
your MIB node. Once snmptranslate works, then come back and try mib2c
again.
I have already done everything needed like setting environment variable for MIB and defining a private MIB file in /usr/share/snmp/mibs ...but still no success. What to do?
You need to do exactly what it says: get the MIB to load first into the parser. Start with using snmptranslate to make sure you can load and parse the MIB:
# export MIBS="+NAME-OF-YOUR-MIB"
# snmptranslate -IR sysSwYear
If that doesn't work, then your MIB isn't being found or loaded because it has errors (or both). If so, run snmptranslate with the -Dparse option and it'll give you way too much information about what it's doing, but it'll let you know where the problems are if you read it all.
Once snmptranslate works as above, then mib2c should work fine (assuming you leave the MIBS environment variable set).
[note: I used export assuming you're using a sh-based shell; use setenv instead and no = sign if you are using a csh-based shell]
If you are on Linux, the default permissions for /var/lib/net-snmp/mib_indexes are 0700 resulting in interesting errors for normal users.
The fix for this is
linux ~ $ mkdir -p ~/.snmp/persist
linux ~ $ echo "persistentDir ~/.snmp/persist" >> ~/.snmp/snmp.conf
Try this if the commands work for superuser but not normal users. Please note that the accepted answer is right but does not address using those commands as a normal user as denoted by '#'.
I found it more intuitive to issue the command as follows:
mib2c -c mib2c.scalar.conf MY-PERSONAL-MIB::sysSwYear.0
The mib must be in one of the directories listed in the output of the following command:
linux ~ $ net-snmp-config --default-mibdirs
Related
In the past, we 'which' command to get the info of the relevant software on our computer, Like:
which python
which git
But now it seems don't work on my MacOS Mojave. Is there anything wrong with my setting?
New edition:
The result will turn out to be like this
AA:~ AA$ which python
/usr/bin/which: illegal option -- -
usage: which [-as] program ...
New edition2:
AA:~ AA$ type --all which
which is aliased to `alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
which is /usr/bin/which
AA:~ AA$ type -all python
python is /Users/AA/anaconda3/bin/python
python is /Users/AA/anaconda/bin/python
python is /usr/bin/python
AA:~ AA$
The alias is what causes the error message. Apparently the alias definition is simply erroneous for your system. It's not clear what defined this alias or why; it seems wrong on several levels, so I doubt it's part of the standard install.
You can remove the alias with unalias which; but I'm guessing it's defined in one of your startup files, and should be removed from there - after this point, it should be gone for good the next time you log in.
But anyway, you should not be using which - it's better to accustom yourself to the POSIX standard command type. It was introduced specifically to replace which but it's apparently still hard to eradicate the old command from people's minds.
For me, this was when something from a yarn global upgrade replaced my system's /usr/bin/which.
/usr/bin/which -> ../local/share/.config/yarn/global/node_modules/.bin/which
Since your error message is exactly the same as the text strings inside that program, it is possible that your issue is from a similar source.
console.error('which: illegal option -- ' + flag)
console.error('usage: which [-as] program ...')
"Fixed" with reinstalling which through the system's package manager (e.g. sudo dnf reinstall which). That may now interfere with whatever JavaScript package depended on that, but I plan on removing those globals, so I will not find out.
Better fix: I feel like my system is dirty now and needs all of its bin files checked... Comparing everything in /usr/local/share/.config/yarn/global/node_modules/.bin to see if it has an equivalent in /usr/bin seems like an easy enough way to look for other points of interference.
for x in $(ls /usr/local/share/.config/yarn/global/node_modules/.bin/*); do
ls -l /usr/bin/"$(basename "${x}")"
done
Then those can be checked against the system's package manager with commands like the following. Then reinstalled if needed.
sudo dnf info ...
sudo dnf provides ...
More:
Seems weird to me that it would allow clobbering existing system programs. At the very least, I would expect it to have used /usr/local/bin instead. That extra system and system-like package management seems to be why they have done away with yarn global in yarn 2 (berry).
I have different packages for sudo yarn global list and yarn global list. Maybe using sudo at some point was my mistake?
P.S. Thanks goes to #tripleee, I was unaware of type. I have seen various other ways of attempting to handle different which programs and different versions of which, along with alternatives like test (and others I have forgotten), but type looks worth trying as a replacement.
P.P.S. Annoying to find out that this OS is configured to run tab completion through which.
P.P.P.S. Yes, I know scripting with the output ls is a bad habit.
The filename of my curl download target is unpredictable and globbing with an asterisk isn't possible. I can download the file using the following command, but only after I've determined its' name in advance:
curl -O -vvv -k -u user:password https://myURL/ws/myfile.zip
How can I tailor my curl command to succeed with an unpredictable target name?
There's no easy way to get a directory listing using HTTP. You can use curl to just print the HTML generated by the site. If there's an index with links to the files on that server, simply running
curl -s -u user:password https://myURL/ws/ | grep .zip
will print HTML-formatted links to the zip files available for download on that page.
Intro:
Like the OP, I had a similar issue scripting the download of a binary- for docker-compose- from Github because the version number keeps iterating making the file name unpredictable.
This is how I solved it. Might not be the tidiest solution, but if you have a more elegant way, ping me a comment and I'll update the answer.
Solution:
I merely used an auto-populating variable that takes the output of curl, prints the 1st line- which will be the most recent release- and thengrep for the release number prefaced by a "v". The result is saved to the the path /home/ubuntu as the arbitrary file name "docker-compose-latest"
curl -L "https://github.com/docker/compose/releases/download/$(curl https://github.com/docker/compose/releases | grep -m1 '<a href="/docker/compose/releases/download/' | grep -o 'v[0-9:].[0-9].[0-9]')/docker-compose-$(uname -s)-$(uname -m)" -o /home/ubuntu/docker-compose-latest
And we validate that we received the correct binary (I'm downloading to a Raspberry Pi which has an ARM processor on 64 bit Ubuntu 20.04 LTS:
file /home/ubuntu/docker-compose-latest
Produces the following feedback on the file:
/home/ubuntu/docker-compose-latest: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=QqyJMzYMWOofWehXt3pb/T7U4zg-t8Xqz_11RybNZ/ukJOlZCpzQuZzBcwSK3b/d6ecQ2m2VfqKb_EQRUZA, stripped
To validate this solution works, just execute the above commands remembering to change the path of the file command if not using Ubuntu.
Conclusion:
Again, might not be the most elegant solution, but it's a solution for how one can download a target with curl that has an unpredictable filename.
I need to install ruby at several sites, but the exact location of the install may be slightly different between the various sites.
I configured and compiled using the -enable-load-relative. This seems to work for my linux install but not for aix. When I configured for linux I used
--enable-load-relative --prefix=blah --exec-prefix=blah/linux_code_rel
I was able to test the relative loading by doing the following:
first with the install dir named linux_code_rel
blah/linux_code_rel/bin/ruby -e " puts 'hello' "
then after renaming the directory to linux_code, ran
blah/linux_code/bin/ruby -e " puts 'hello' "
both times I got back hello
When I did the same thing for aix, it does not seem to work.
I configured and installed using
--enable-load-relative --prefix=blah --exec-prefix=blah/aix_code_rel
after installing if I run
blah/aix_code_rel/bin/ruby -e "puts 'hello' "
I get back
hello
if i rename aix_code_rel to aix_code and run
blah/aix_code/bin/ruby -e "puts 'hello' "
I get
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
creating a symbolic link using ln -s aix_code aix_code_rel, seems to fix this, which indicates that the install is always looking for the code to be found using the path blah/aix_code_rel , despite the fact that i configured with --enable-load-relative
I seem to be able to get past this by setting the RUBYLIB env variable, but this seems messy, especially given that the linux install seems to work with the relative loading.
Anyone have an idea what I might be doing wrong? Is there any other why I can set the default LOAD_PATH? Maybe some post install configuration file?
I've not tried that option but on AIX that will be some trick to get it to work.
If you find an executable or a shared library (like miniruby or libruby.so.xxxxx) and do:
dump -H miniruby
you will see output that shows what it depends upon. Below the "Import File Strings" you will see a list. The 0th entry is what that particular executable or shared library uses for its "libpath". You could make those relative paths. It does work. But that introduces a security risk (which I just recently was told of) that the Ruby build process tries to avoid.
This is if LIBPATH is not set in the environment. If LIBPATH is set in the environment, then it will use that path in all cases.
Oh... there is actually an exception to this. (I'm editing as I'm typing) The 1st through nth entries in the import file strings list can be absolute paths in which case not even LIBPATH will alter the search since there is no search done.
What might work is to wrapper "ruby" in a script that sets LIBPATH and then exec's ruby using the same arguments. Something like:
#!/bin/sh
export LIBPATH=/blah:/ble/blah:/usr/lib:/lib
exec real-ruby "$#"
The small dance that you have to do or worry about is if ruby looks at argv[0] and does different things based upon its name. I don't think it does. And the other part is that you might need to set GEM_HOME and some of the other ruby environment variables.
The other real world suggesting is to create a symlink from where it is suppose to be installed to the place that it is installed. Do this for the bin and lib directory and that might work as well.
Before I debug or execute a program on my system at work, I have to source a file that contains numerous paths and settings that are specific to each project. Is there a way I can do this from gdb? I tried putting it into a .gdbinit file in the working directory, but that doesn't seem to be working. I tried to see if the environmental variable was set by typing
(gdb) shell echo $MY_VAR
and it was blank. Any ideas?
Basically to set the environment variable in the command prompt, you can use the set environment varname [=value]. More information is present here. Since you have noted down there are huge number of paths to be set, you can add them to a file like myGdbSrc and then load them explicitly using source [-s] [-v] filename. You can find details on loading a file here.
I have tried both of them and it works.
HTH.
PS: I have tried it on GNU GDB 6.6 version on SUSE Linux. However, it must work across all version since it seems to be basic command.
How about writing a wrapper script which sources your settings before loading gdb?
E.g. some trivial example:
#!/bin/sh
source my-script-which-sets-up-the-environment
gdb $*
This can of course also add arguments to the gdb invocation to setup paths, load a gdb script, etc.
I can find the tool command in my filesystem under:
/Applications/Xcode.app/Contents/Developer/usr/bin/otool
If I specify that entire path, otool will work.
/Applications/Xcode.app/Contents/Developer/usr/bin/otool -tV hello -p _main
However, since I have to be inside the folder of the hello.c file I'm referencing, bash won't find otool automatically if I just type
otool -tV hello -p _main
I've had this same problem with a number of commands. Is there any way to set up bash so it automatically finds otool (and similar commands), without me having to writing out the entire path name each time? Thanks!
Note: If it matters, I'm using a Mac.
Note 2: I've read through a ton of the "Command not found" threads but none seem to answer the question of teaching bash where to look for a command by default. I feel like this question should have been answered somewhere, but haven't come across it yet. Since the only programs I'll be working with any time soon will be iOS/Xcode related, this is worthwhile shortcut.
PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
Put this in your ~/.bashrc to have it persist.
You can also Try using alias to do this. e.g.
$ alias otool='/Applications/Xcode.app/Contents/Developer/usr/bin/otool'
You can also add this in your bashrc/profile file.