Why doesn't wget send auth field for every access? - authentication

i am using wget in a windows.bat loop for accessing my Arduino server every 10 secs. What i see is that in ~half of the accesses, it does not send the "authorization basic..." Field and so the Arduino server reject and send a request to authenticate instead of executing the command and returning ok status. Can someone help me out?
wget is called as follows
wget --user=abc --password=def --append-output=wgetout.txt --output-document=new.html 192.168.1.123/light

Related

expect script doesn't work on ssh session

I login our company server by ssh, but the server ask my password and otp token.
Since i know my otp secret, so i can generate my otp in my script.
the prompt looks like this:
$ ssh mike#relay.office.com
Your password:
Your token:
let's assume my password is "123", and token is "456"
I wrote a expect script like this, which is supposed to work
#!/usr/bin/expect
spawn ssh mike#relay.office.com
expect "password:"
send "123\n"
send "456\n"
interact
However the prompt just like this:
$ ./expect.sh
Your [EMAIL] password:
Your [VPN] token:
^[[?65;1;9cInvalid credentials
You see, the ssh server return some massy code followed by "Invalid credentials"
I don't understand where the messy code came from.
In normal situation. Even i type the wrong password or token, it will just prompt "Invalid credentials" without any messy code. Is it some sort of anti-script login method from our ssh server?
Some Supplyment
Per answer below, i need to clarify, i forget to paste expect line in my script before. But even with it, the problem stands still.
And another thing i didn't mention before, but maybe related. when i type ssh mike#xxx.com. the server returned a QR code.(yeah, QR code in terminal.) it contains color escape as well as some unicode characters. I'm not sure if expect has any bug on handling unicode characters
The "messy code" is a terminal escape sequence, probably intended to change the colour or font of the following error message.
But the main problem here is that as written, your script will launch the ssh command and then immediately send the following lines, without waiting for ssh to connect to the remote machine. You should use expect commands to wait for each prompt before sending the response, e.g.
spawn ssh mike#relay.office.com
expect "password:"
send "123\n"
expect "token:"
send "456\n"
interact

SSH with Chilkat in VB6; but maybe generaly

I have written an application for SSH, but the originally used library is no longer developed and has old methods of encryption. Thus, it is not usable for contemporary devices. I am looking for alternatives and I found Chilkat.
I am able to start connecting to the device (Cisco switch for instance), but communication behaves in strange ways.
The basic principle of my program is based on talking client (my program) and server (Cisco switch). After the login is done, I get prompt saying that I would get into priviledged mode by command enable. I recongize this need by sign > at the end of prompt. I send command enable and awaiting prompt Password: After I get it I a send password. I am using two components and timer in this time :
success = ssh.ChannelSendString(channelNum, commandToSend & Chr(13), "ansi")
and
auxStr = ssh.GetReceivedText(channelNum, "ansi")
when I get word Password: in receiving text, I send password string like a commandToSend
but I get % Access denied
I am pretty sure that the password is OK; it seems like one extra enter is sent via connection, because during next returned text is this message :
Translating "passwordString"...domain server (255.255.255.255)
it indicates that passwordString was sent into the switch after message
% Access denied
not like an answer to Password: prompt.
I made debugging in the code to see what my program is sending to switch, but everything seems to be correct. Maybe some mistake in chilkat component ?
Has anybody similar experience ? Or explanation of this behaviour and advice how to solve it, please ?
Send the "enable" command (or just "ena") followed by a single CHR(13). Then get the output from the SSH server, which should be the "Password:" prompt. Then send the password followed by the CHR(13). Then get the output. The send each command terminated by a single CHR(13) and get the output after each command.

Execute internal server script in grafana

I would like to know how to execute a script in response to an alert in Grafana.
I want to execute the script in a shell when the temperature is greater than 25C. The script connects to an ESX server and turns off all VM's.
I've created the script that connects to the ESX server, but I'm not sure how to call it from Grafana.
Use the Alert Webhook notifier. It sends a json document to the webhook url every time an alert is triggered.
You will need to build some sort of backend service (in any language/web framework) that can listen to HTTP requests. This service would take in the JSON document, parse it and then shell out to execute your script.

I want to send the following web page request using a cronjob with raspberry pi

can anyone point me in the right direction?
I want to send the following webpage request using a cron job with raspberry pi,
http://10.0.1.224/socket1On
thanks
Install curl using aptitude install curl, then crontab -e and...
0 * * * * curl http://10.0.1.224/socket1On >/dev/null
(This runs once on each full hour - adjust as necessary of course.)
This throws away the answer; if you need it, you can save it to some file, or course. Errors will be mailed to whatever mail account you let your mails get forwarded to, by cron.

Notification when laptop is switch on (boot)

I need to know, is that possible to get a notification through email whenever my laptop is switched on or is connected to internet ?
An alternative is to get notification when set service 'Starts' on system boot.
Need C# code for this service.
If you have a web site somewhere and access to the log files, install wget or curl and then run this command:
wget -q http://your.site.com/MyLaptopIsConnected
Just search the error logs for this string to see when your laptop came online. Put the command in a BAT/CMD file and tell Windows to run it once the computer starts with the scheduler.