Issue while entering response on console [closed] - python-2.7

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am connecting to machine using Telnet function, pushing some file to it using Putty and till date it worked fine. But now all of sudden, it has started throwing me an error while I am trying to push some file to the machine using subprocess.Popen().
The error is :
Result: WARNING - POTENTIAL SECURITY BREACH!
The server's host key does not match the one PuTTY has
cached in the registry. This means that either the
server administrator has changed the host key, or you
have actually connected to another computer pretending
to be the server.
Update cached key? (y/n, Return cancels connection) Connection abandoned.
Lost connection
I want to add one step in my scrip that, if console has something like this, then it enter "Yes/y" on console.
I have tried this thing to make it over :
if 'Result: WARNING - POTENTIAL SECURITY BREACH!' in sys.argv:
raw_input("y\n")
time.sleep(1)
But it is not working.. Any help on this!!!

For the first part of your question, you should look in the Registry key HKEY_CURRENT_USER\SoftWare\SimonTatham\PuTTY\SshHostKeys to remove the host computer whose host key has changed (see https://superuser.com/questions/197489/where-does-putty-store-known-hosts-information-on-windows).
For the second part, raw_input() is used to get input from the user, not for submitting values to a subprocess. I'm not sure, but I think that PuTTY's pscp would be getting it's y/n value from stdin, so you could either use subprocess's Popen() to always pass in a "y" just in case (see Python - How do I pass a string into subprocess.Popen (using the stdin argument)?) or you can try passing pscp the "-batch" argument, which sounds like it shouldn't prevent the prompt (see http://the.earth.li/~sgtatham/putty/0.62/htmldoc/Chapter5.html#pscp-usage).

Related

Failed Open Snapshot VirtualBox 6 VERR_SSM_DATA_UNIT_FORMAT_CHANGED [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
Anybody else failing to open snapshots once they upgraded their VirtualBox from v5 to v6? Snapshots that were opening just fine are now failing for me with this error ...
HGCM#0: Bad auto mount point size: 0x5
[ver=3 pass=final] (VERR_SSM_DATA_UNIT_FORMAT_CHANGED).
Result Code: E_FAIL (0x80004005)
Component: ConsoleWrap
Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed}
Some very old snapshots are able to open; but most new ones and ALL the ones I save now using VirtualBox 6 are failing to open. Same error above.
My host is Windows10 and the saved VMs are Ubuntu18 guests.
Disclaimer: It should not be an excepted solution as your saved state will be lost.
As I don't have any sensitive data in the saved state. I have discarded the saved state and it works fine for my case.
EDIT: in some cases it looks like if you take a snapshot using the saved state, and then discard the saved state you might be able to recover back to where your saved state was
Steps
Right Click on the OS
Select Discard Saved State... in the context menu.
Screenshot
Host OS: Windows 10, Guest OS: Ubuntu 18.04, on Virtual Box 6.0.0
I have resolved this problem by installing Oracle_VM_VirtualBox_Extension_Pack-6.0.4.vbox-extpack for my VirtualBox-6.0.4-128413-Win

Is there a way to register hotkey on windows without conflict? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm writing a Windows program and I need to register a hotkey. However, I'm afraid of the conflicts caused by RegisterHotKey().
Furthermore, Key Events are blocked when you triggered a Hotkey message. For example, you call RegisterHotkey(0, 0, MOD_NOREPEAT | MOD_ALT, VK_UP) To register hot key ALT + ↑. If you press ALT + ↑ in explorer.exe, explorer.exe won't receive this message(Originally ALT + ↑ is go up a level in explorer.exe).
Is there a way to register hot key without conflicts and blocking?
The MSDN page for RegisterHotKey says:
RegisterHotKey fails if the keystrokes specified for the hot key have
already been registered by another hot key.
along with:
Return value
Type: BOOL
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error
information, call GetLastError.
In other words, if(!RegisterHotKey(...)) ... deal with error ... would catch various forms of "didn't work", including that the hotkey is already in use - you need to look at GetLastError to tell the difference between "key already in use" and others.
I think the whole point of registering a hotkey is that YOUR application ALWAYS gets that keypress, regardless of what is going on. Which of course is a bit annoying if it happens to be popular key in some other application, but it's still the point of registering a hotkey. If you don't like that effect, then don't register a hotkey, or use a more obscure combination that is less likely to be used by some other application. Not sure how else this can be solved - exactly what would you like the system to do if you run IE together with your application, and ALT-uparrow is pressed?

pass data from a python application to a running c++ application [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I coded to applications one in python the other one in c++. In the middle of the python app I need to run the c++ app pass some input to it and receive the output. I already know that I can call the c++ app from python using subprocess but since that c++ app has to do some initial calculations each time it is called it makes my program really slow. So what I was looking for is this:
put my c++ app in an infinite while loop and keep it running. Then in my python app whenever I need a call to the c++ app just pass the data and get the output. This way i can avoid repeating the initial state every time I need to make this call.
Is there anyway to do this? Like writing another application that controls all of these. Also there can be multiple instances of the python app running but I want to have just one of the c++ app running since it takes a lot of memory
Using subprocess.Popen you can open a process and keep it open, use the stdin and stdout to communicate with it. When you open the process use: stdout=subprocess.PIPE, stdin=subprocess.PIPE .
You can then write to process.stdin and read from process.stdout the output of the c++ program.
You can do it with boost python. Design a class that perform the initial computation in its constructor and a method to perform the computation. You wrap it and instantiate it from python once.
subprocess solution is possible too, as asafpr answered.
You also can set a XML-RPC server in the C++ app and call it from Python with with xmlrpclib module.

Putty - Can't See Top of Error Stack Trace [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am coding on Putty (in C++ for what it's worth) and I am currently encountering an error that gives me a really long stack trace. Apparently, the trace is so long that Putty won't let me scroll to the very top where it originated (where I typed "make"). Is there any way around this (except by obviously fixing the error)?
There are two ways.
Change the Window buffer size. Open Putty, load the connection (don't double-click or hit open), click on Window on the left panel and increase the Lines of scrollback to something like 3000 (I think the default is 200).
Same way, load the connection, and then on the left panel under Session you will have the sub-category logging where you can set a file where the entire session history will be recorded.
To increase the lines of scrollback, before you make a putty connection, click on the category Window and increase the lines of scrollback to 10000 or 20000 as may suit you.

Linux is there any way to set IP address permanently using C/C++? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I reffered many links to change IP address using C/C++. But I found that its only changing the setting temporary (untill the next reboot) and Once the system is rebooted , the all settings are gone.
I referred below links to achieve it.
Qt: Setting the IP
Set IP address using SIOCSIFADDR ioctl
etc. but ended up with temporary settings (remains untill the next reboot)
Is there any way to change the settings permanently through C/C++ ?????
Please direct me to the right path.
At startup Linux uses some configuration file to assign IP-address to an interface. Each distribution has its own file dedicated for that purpose. You should consult your distribution Wiki on the topic of how to set an IP-address at startup.
In general it is an administrative task (i.e. should not be configured dynamically via some custom program), but if you really want to do it in your C/C++ program, then you should parse the network configuration file and place there the address you want to assign at startup.