I am trying to run the batch file which will do snmp walk for two AIX server. Here the problem is for the first device the walk is completed successfully but for the second device it is throwing "SNMP Timeout Error".
I have tried using the batch file which i created and using snmpwalk.exe. In snmpwalk.exe for both device the walk is happening but through batch file the device which is processing first will give the correct result and for the second one it is throwing timeout error.
#echo off
"C:\Program Files (x86)\test\snmpwalk.exe" -v3 -u test -a MD5 -A XXX -x DES -X YYY 172.21.20.19 .1.3
"C:\Program Files (x86)\test\snmpwalk.exe" -v3 -u test -a MD5 -A XXX -x DES -X ZZZ 172.21.20.21 .1.3
In environment where multiple devices enabled with SNMP, the snmpEngineID must be unique as it is the unique identifier.
In some cases, using cloned devices creates duplicate snmpEngineID in network results in above mentioned behavior (i.e., throwing SNMP timeout). In order to avoid this, do reset the hostID once cloned. Reference.
Related
I have written a bash script which starts a tcpip port and connects my device to my laptop for wireless debugging. This is the script at /bin/device_added.sh:
#!/bin/bash
adb shell ip -f inet addr show 2> /tmp/scripts.log
ip=$(adb shell ip -f inet addr show | egrep -o '192.*/' | sed 's/.$//')
adb tcpip 5555
adb connect $ip:5555
echo "USB device added at $(date)" >>/tmp/scripts.log
After configuring permissions with chmod, this works flawlessly on its own. But I want this script to be triggered whenever I plug in usb. I followed this answer to try to make this work. I created a 80-test.rules file at /etc/udev/rules.d and added this:
SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", RUN+="/bin/device_added.sh"
and reloaded the rules file using: sudo udevadm control --reload
Whenever I plug in usb, the script gets run(the date gets logged in scripts.log) but my device doesn't get connected. What am I doing wrong? Why does the script work properly when I run it manually but not when it is triggered through udev?
Edit: On basis of #markp-fuso's and #Charles Duffy's comment, I tried logging the error to /tmp/scripts.log file. Turns out I am getting this error:
line 3: adb: command not found
Now the strange part is, I got this error earlier but I solved it by placing the shell command before the tcpip command(atleast that worked when I ran the script directly). How am I supposed to deal with this error now?
Update:
As #markp-fuso pointed out, the problem was that environment variables weren't accessible to that script. Hence I created a the adb's location as a variable in the script and then made that used that variable as throught. My script now:
#!/bin/bash
adb=/home/pranil/Android/Sdk/platform-tools/adb
$adb shell ip -f inet addr show 2> /tmp/scripts.log
ip=$($adb shell ip -f inet addr show | egrep -o '192.*/' | sed 's/.$//')
$adb tcpip 5555
$adb connect $ip:5555
echo "USB device added at $(date)" >>/tmp/scripts.log
This solved the error I was getting in logs but still the adb doesn't get connected at the required port. I have no idea where I am going wrong now. One more thing, after my script runs, the offline emulator is no longer shown as an output of abd devices command.
I run this command on my remote machine and it gives the desired results:
local# /usr/local/sbin/i2c_eeprom show-serial
serial = 5070045
When I run it from a remote server it doesn't work:
server# sshpass -f pass.out ssh 192.168.1.1 -n -o "StrictHostKeyChecking=no" "i2c_eeprom show-serial"
serial = TBD Serial
Why isn't the result being display correctly? I've tried creating a script file first and redirecting the output to a remote file, then reading the file but I don't get the same results. I always get TBD Serial. Any suggestions on how to run this command remotely and behave as it does locally?
I solved this problem by creating a bash script on the server as follows:
#!/bin/bash -l
/usr/local/sbin/i2c_eeprom show-serial
I copy this to the client and execute it via ssh. The key is the "-l" in the shebang line. I found this solution here. What does this command do? "exec bash -l"
I have tectia ssh server in a windows environment.
When I use sftpg3 -B cmd.txt username#host that works fine. The only problem is that it doesnt let me execute files remotely, it only lets me move files. It reads the commands from cmd.txt but since I cant execute anything it ignores the commands.
Well when I do the same thing but use sshg3, it doesnt recognize the -B flag at all.
SSHG3 -B cmd.txt username#host
cmd.txt' is not recognized as an internal or external command,
operable program or batch file.
I've tried putting -B "cmd.txt"
I tried just putting the cmd.txt contents in the same script instead of housing them in cmd.txt and getting rid of -B, but it doesnt run them that way either.
The docs dont have much to go off of. All it says is use -B for batch processing.
Contents of cmd.txt:
D:
cd Library
cd Backup
parseLibrary.cmd
exit
Trying to sshg3 into a host, navigate to a path and run a batch file on that host.
Any ideas?
-B, --batch-mode
Uses batch mode. Fails authentication if it requires user interaction on the terminal.
Using batch mode requires that you have previously saved the server host key on the client and set up a non-interactive method for user authentication (for example, host-based authentication or public-key authentication without a passphrase).
It does use public key authentication, there is no user interaction needed on the terminal.
Noticed this on the docs for sftpg3
-B [ - | batch_file ]
The -B - option enables reading from the standard input. This option is useful when you want to launch processes with sftpg3 and redirect the stdin pipes.
By defining the name of a batch_file as an attribute, you can execute SFTP commands from the given file in batch mode. The file can contain any allowed SFTP commands. For a description of the commands, see the section called “Commands”.
Using batch mode requires that you have previously saved the server host key on the client and set up a non-interactive method for user authentication (for example, host-based authentication or public-key authentication without a passphrase).
I'm guessing batch file is different than batch mode?
*I figured it out. You have to use the -B flag for every command you want to execute.
I figured it out. You have to use the -B flag for every command you want to execute.
sshg3 user#host -B dir -B ipconfig -B etc.cmd
I am using winpower to hibernate 2 computers in the event of power failure.
I use the command.
"C:\Program Files\PSTools\psshutdown.exe" -h -t 1 \\COMPUTER -u xxx -p yyy
(with the quotes)
When I use it directly via command line this works fine, but when I use it inside the app it does not work, I suspect a permission issue of some sort.
Can anybody think what the issue might be.
Shrewsoft [1] provides a command line interface for setting up the vpn tunnel automatically without any user intervention, such as by using the following command
ikec -u username -p password -r configuration -a
IS there any way to detect if the connect attempt was successful such as by reading live logs and how can we terminate the vpn tunnel after some time using the command line. Any help will be appreciable.
By looking at the terminal output from ikec -u username -p password -r configuration -a, you can tell if the connection was successful; if the output has a line ii : tunnel enabled, that means the connection was successful and should work. If you get a message such as >> : detached from key daemon or failed to connect to key daemon, it means there was a problem with the connection (https://askubuntu.com/a/793336/705434 suggests running sudo /usr/sbin/iked for a solution to this particular error). To exit the ikec command, just type q into the terminal.
EDIT: it looks like this page (https://gist.github.com/fschabmeyer/22b759994cf852df7e9b) has a shell script that can handle the detection, you should be able to add a case to exit the command automatically after a certain amount of time.