1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- // example_ssh2.cpp : 定义控制台应用程序的入口点。
- //
- #include "stdafx.h"
- #include "example_ssh2.h"
- #include "WinSsh2Proc.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // 唯一的应用程序对象
- CWinApp theApp;
- using namespace std;
- void Split(std::string str1, std::string str2, std::vector<std::string> &vt)
- {
- if ( str1.size() == 0 || str2.size() == 0 )
- return;
- int npos = str1.find(str2);
- while( std::string::npos != npos )
- {
- vt.push_back(str1.substr(0, npos));
- str1 = str1.substr(npos + str2.size());
- npos = str1.find(str2);
- }
- if ( str1.size() )
- vt.push_back(str1);
- }
- int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
- {
- int nRetCode = 0;
- // 初始化 MFC 并在失败时显示错误
- if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
- {
- // TODO: 更改错误代码以符合您的需要
- _tprintf(_T("错误: MFC 初始化失败\n"));
- nRetCode = 1;
- }
- else
- {
- // TODO: 在此处为应用程序的行为编写代码。
- CWinSsh2Proc winssh2;
- if ( winssh2.InitSocket() )
- {
- if ( winssh2.ssh2_connect("10.126.69.29", "wangjianfeng", "wangjianfeng@2021"))
- {
- std::string data;
- winssh2.ssh2_execute_command("ls", data);
- std::vector<std::string> strList;
- Split(data, "\n", strList);
- winssh2.ssh2_execute_command("md5sum /scbc_data/exchange/BAK_RT2841_2851_dailybuild/DailyBuild_RT2851_1231/USB/V8-T851T01-debug123103.img", data, 100000);
- winssh2.ssh2_execute_command("sha1sum /scbc_data/exchange/BAK_RT2841_2851_dailybuild/DailyBuild_RT2851_1231/USB/V8-T851T01-debug123103.img", data, 10000);
- winssh2.ssh2_execute_command("sha256sum /scbc_data/exchange/BAK_RT2841_2851_dailybuild/DailyBuild_RT2851_1231/USB/V8-T851T01-debug123103.img", data, 10000);
- }
- winssh2.ssh2_sftp_download("rt2851/Buildimg/V8-T841T01-LF1V001/Images/USB/build.prop", "D:\\sat\\c.img");
- }
- }
- system("pause");
- return nRetCode;
- }
|