shell 命令结果无法处理

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qdqht2009/article/details/52452803

某些命令输出不能直接写入管道进行处理,例如

python -v需要重定向输出之后才能进行处理

python -V 2>&1|cut -d' ' -f2



ttt=`gcc 2>&1|grep 'not found'`
if [ $ttt=="" ];then
echo "gcc 已安装"
else
echo "安装gcc"
unzip gccrpm.zip
cd gccrpm
rpm -Uvh *.rpm --nodeps --force
cd ..
fi


mip=`ifconfig|grep 'inet addr:'| grep -v '127.0.0.1'|cut -d: -f2 | awk '{ print $1}'`
echo "mip:$mip"

展开阅读全文

存储空间不足,无法处理命令

06-17

raised exception class EOutOfResources with message "存储空间不足,无法处理命令"rn我开了5个线程(主要用于读取数据并将数据显示到主界面上,并保存数据成TXT文档),由于错误是不定期的,并且没有指到错误的那一行代码,所以无从下手,请高手指教。下面是我的第二个线程,其它其它类似rnunit UnitTwo;rnrninterfacernrnusesrn Classes,Graphics,rn SysUtils,inifiles,rn windows;rnrntypern TwoThread = class(TThread)rn Privatern pull:boolean;rn val161DF,val161EF,valCC,valDD:String;rn procedure PullOut();rn procedure WriteDateExcel(Quit:boolean);rn procedure StopAndFreeThread(); //停止与释放线程rn procedure GetLightTwo(PortAddr: Word);rn Protectedrn procedure Execute; Override;rn Publicrn constructor create();rn end;rnrnimplementationrnrnuses UnitMain,rn UnitFunctionModul;rnrnconstructor TwoThread.create();rnbeginrn inherited create(false);rn self.FreeOnTerminate:=true;rn Testing2:=true;rn pull:=false;rnend;rnrnprocedure TwoThread.Execute;rnvarrn TimeF,TimeE:DWORD;rn TimeS:integer;rn RTS:Byte;rnbeginrn HandControl2=false then //自动控制rn beginrn TimeF:=GetTickCount();rn repeatrn GetLightTwo($161); //读输入卡161的地址rn sleep(5);rn if (val161EF='0') and (val161DF='1') thenrn beginrn sleep(200);rn break;rn end; rn TimeE:=GetTickCount();rn TimeS:=TimeE-TimeF;rn IF TimeS>=2000 Thenrn beginrn EndTest2:=true;rn InPad2:=TRUE;rn Testing2:=false;rn exit;rn end;rn until TimeS>=2500;rn end; rnrn IF WorkChose2=true thenrn beginrn frmmain.LEDYesOrNo.Scrolling:=True;rn frmmain.LEDYesOrNo.SegOnColor:=clLime;rn frmmain.LEDYesOrNo.Caption := '>>> >>>';rn SetLight($155, $FD, true); //工位2升rn //sleep(200);rn SetLight($155, $BF, true); //工位2触点升rn //SLEEP(200);rnrn GetLight($191); //读输入卡191的地址rn if (Val191_6='0') and (Val191_5='0') then //工位板,触点没到位情况rn beginrn //frmmain.LEDYesOrNo.Caption := 'ERROR';rn end;rn rn RTS:=0;rn repeatrn pull:=false;rn SetLight($156, $FB, true); //测试rn //SLEEP(200);rn SetLight($156, $FB, FALSE); //测试rn //SLEEP(1500);rnrn //GetPortVal($161, @VoltH, 1);rn //VoltH1 := VoltH and $FF;rn GetLightTwo($162); //读输入卡162的地址rn sleep(3);rn //判断是否合格rn frmmain.LEDYesOrNo.Scrolling:=false;rnrnrn valDD:= '0';rn valCC:= '1';rnrnrn if (valDD = '0') and (valCC = '1') thenrn beginrn frmmain.LEDYesOrNo.SegOnColor := Col2_Qual;rn frmmain.LEDYesOrNo.Caption := 'OK!'; //合格rn endrn else if (valCC = '0') and (valDD = '1') thenrn beginrn frmmain.LEDYesOrNo.SegOnColor := Col2_NotQual;rn frmmain.LEDYesOrNo.Caption := 'NO!'; //不合格rn SetLight($156, $F7, TRUE); //复位rn SLEEP(100);rn SetLight($156, $F7, FALSE); //复位rn //SLEEP(3);rn pull:=True; //不合标识rn end;rn RTS:=RTS+1;rn until (RTS>=W2.RepTimes) or (pull=false); //当重测次数到达或合格时退出rnrn SetLight($155, $BF, false); //工位2触点降rn IF pull=false thenrn beginrn //sleep(300);rn //if HandControl2=false thenrn WriteDateExcel(FALSE); //写数据rn SetLight($155, $FD, false); //工位2降rn EndTest2:=true;rn InPad2:=TRUE;rn Testing2:=false;rn endrn elsern beginrn if HandControl2=false then WriteDateExcel(true); //写数据rn //sleep(300);rn PullOut(); //调用不合格过程rn end;rn endrn elsern beginrn frmmain.LEDYesOrNo.Caption:='';rn if HandControl2=false then WriteDateExcel(false);rn EndTest2:=true;rn InPad2:=TRUE;rn Testing2:=false;rn end;rnend;rnrn//--------------------------------读信号----------------------------------------rnprocedure TwoThread.GetLightTwo(PortAddr: Word);rnvarrnVoltH:DWORD;rnVoltH1:word;rnstr,val:string;rnbeginrn val:='';rn str:='';rn GetPortVal(PortAddr,@VoltH,1);rn VoltH1:=VoltH and $FF;rn val:=inttoBin(VoltH1);rn case length(val) ofrn 8: str:=val;rn 7: str:='0'+val;rn 6: str:='00'+val;rn 5: str:='000'+val;rn 4: str:='0000'+val;rn 3: str:='00000'+val;rn 2: str:='000000'+val;rn 1: str:='0000000'+val;rn 0: str:='00000000';rn end;rnrn case PortAddr ofrn 353:begin //$161rn val161DF:=copy(str,3,1); //工位板信号rn val161EF:=copy(str,4,1); //电机信号rn end;rnrnrn 354:begin //$162rn //frmmain.Memo1.Lines.Add('162: '+str);rn valCC:=copy(str,3,1);rn valDD:=copy(str,4,1);rn end;rn end;rnend;rnrn//-----------------------------不合格将产品推出费品区---------------------------rnprocedure TwoThread.PullOut;rnvarrnpull2:boolean;rnbeginrn pull2:=false;rn //GetLight($151); //读输入卡151的地址rn sleep(1);rn if val151_3='0' thenrn beginrn SetLight($156, $DF, true); //报警rn repeatrn sleep(6);rn if val151_3='1' thenrn beginrn SetLight($157, $7F, true); //工位2推出rn sleep(800); //推出时间rn SetLight($157, $7F, false); //工位2推出后缩回来rn SetLight($155, $FD, false); //工位2降rn EndTest2:=true;rn InPad2:=TRUE;rn Testing2:=false;rn pull2:=true;rn SetLight($156, $DF, False); //取消报警rn exit;rn //StopAndFreeThread; //停止与释放线程rn end;rn until (val151_3='1') and (pull2=true); //直到有空闲位置时rn endrn elsern beginrn SetLight($157, $7F, true); //工位2推出rn SetLight($156, $DF, true); //报警rn sleep(800); //推出时间rn SetLight($156, $DF, false); //报警rn SetLight($157, $7F, false); //工位2推出后缩回来rn SetLight($155, $FD, false); //工位2降rn sleep(50);rn EndTest2:=true;rn InPad2:=TRUE;rn Testing2:=false;rn pull2:=true;rn StopAndFreeThread; //停止与释放线程rn end;rnend;rnrn//----------------------------------停止与释放线程(包括内存)--------------------rnprocedure TwoThread.StopAndFreeThread;rnbeginrn self.Terminate; //终止线程rn self:=nil; //线程清空rn self.Free; //线程释放 rnend;rnrnprocedure TwoThread.WriteDateExcel(Quit: boolean);rnvarrni,j,k:integer;rn Inifile: Tinifile;rn FilePath: string;rnbeginrn FilePath := ExtractFilePath(ParamStr(0));rn Inifile := TIniFile.Create(FilePath + 'Com.ini');rn DataEnd[1,1]:=True; rntryrn for i:=1 to 5 dorn beginrn if (DataEnd[i,1]=True) and (DataEnd[i,2]=false) thenrn beginrn //TestOfEnd:=2;rn DataEnd[i,2]:=true;rn if frmmain.LEDYesOrNo.Caption= '>>> >>>' then Data[i,3]:='' else Data[i,3]:=frmmain.LEDYesOrNo.Caption;rn if (Quit=true) or (TestOfEnd=2) thenrn beginrn if (TestOfEnd=2) and (Quit=false) thenrn beginrn QualifiedNum:=QualifiedNum+1; //合格数量计算rn Inifile.WriteInteger('Total','QualNum',QualifiedNum);rn FrmMain.LabNowSum.Caption:='合 格 量:'+Inifile.ReadString('Total','QualNum','');rn Inifile.Destroy;rn end;rn for j:=1 to 5 do DataEnd[i,j]:=false;rn WriteData(Data[i,1],Data[i,2],Data[i,3],Data[i,4],Data[i,5],rn Data[i,6],Data[i,7],Data[i,8],Data[i,9],Data[i,10],rn Data[i,11]);rn for k:=1 to 11 do Data[i,k]:=''; //清空数据rn end;rn break; rn end;rn end;rnexceptrn exit;rnend;rnend;rnrnend.rn 论坛

存储空间不足,无法处理命令

01-08

高手们,帮帮忙哇。这是由于什么原因造成的错误哇,搞的我快纠结死了。rnrnSee the end of this message for details on invoking rnjust-in-time (JIT) debugging instead of this dialog box.rnrn************** Exception Text **************rnSystem.ComponentModel.Win32Exception: 系统找不到指定的文件。rn at System.Drawing.BufferedGraphicsContext.CreateCompatibleDIB(IntPtr hdc, IntPtr hpal, Int32 ulWidth, Int32 ulHeight, IntPtr& ppvBits)rn at System.Drawing.BufferedGraphicsContext.CreateBuffer(IntPtr src, Int32 offsetX, Int32 offsetY, Int32 width, Int32 height)rn at System.Drawing.BufferedGraphicsContext.AllocBuffer(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)rn at System.Drawing.BufferedGraphicsContext.AllocBufferInTempManager(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)rn at System.Drawing.BufferedGraphicsContext.Allocate(IntPtr targetDC, Rectangle targetRectangle)rn at System.Windows.Forms.Control.WmPaint(Message& m)rn at System.Windows.Forms.Control.WndProc(Message& m)rn at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)rn at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)rn at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)rnrnrn************** Loaded Assemblies **************rnmscorlibrn Assembly Version: 2.0.0.0rn Win32 Version: rn CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dllrn----------------------------------------rn冷链仓储环境监管系统rn Assembly Version: 4.12.221.1247rn Win32 Version: 4.12.221.1247rn CodeBase: file:///C:/COLDCHAIN/冷链仓储环境监管系统.exern----------------------------------------rnMicrosoft.VisualBasicrn Assembly Version: 8.0.0.0rn Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000)rn CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dllrn----------------------------------------rnSystemrn Assembly Version: 2.0.0.0rn Win32 Version: rn CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dllrn----------------------------------------rnSystem.Windows.Formsrn Assembly Version: 2.0.0.0rn Win32 Version: rn CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dllrn----------------------------------------rnSystem.Drawingrn Assembly Version: 2.0.0.0rn Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)rn CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dllrn----------------------------------------rnSystem.Runtime.Remotingrn Assembly Version: 2.0.0.0rn Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)rn CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dllrn----------------------------------------rnSystem.Configurationrn Assembly Version: 2.0.0.0rn Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)rn CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dllrn----------------------------------------rnSystem.Xmlrn Assembly Version: 2.0.0.0rn Win32 Version: rn CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dllrn----------------------------------------rnACLCommunicationProtocolsrn Assembly Version: 3.11.705.2335rn Win32 Version: 3.11.705.2335rn CodeBase: file:///C:/COLDCHAIN/ACLCommunicationProtocols.DLLrn----------------------------------------rnSystem.Windows.Forms.DataVisualizationrn Assembly Version: 3.5.0.0rn Win32 Version: 3.5.30729.5681rn CodeBase: file:///C:/COLDCHAIN/System.Windows.Forms.DataVisualization.DLLrn----------------------------------------rnACLVisualrn Assembly Version: 3.11.623.125rn Win32 Version: 3.11.623.125rn CodeBase: file:///C:/COLDCHAIN/ACLVisual.DLLrn----------------------------------------rnAccessibilityrn Assembly Version: 2.0.0.0rn Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)rn CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dllrn----------------------------------------rnACLGenericrn Assembly Version: 3.11.714.935rn Win32 Version: 3.11.714.935rn CodeBase: file:///C:/COLDCHAIN/ACLGeneric.DLLrn----------------------------------------rnSystem.Webrn Assembly Version: 2.0.0.0rn Win32 Version: rn CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dllrn----------------------------------------rnACLUnitsrn Assembly Version: 3.11.908.1440rn Win32 Version: 3.11.908.1440rn CodeBase: file:///C:/COLDCHAIN/ACLUnits.DLLrn----------------------------------------rnACLDbUnitsrn Assembly Version: 1.11.628.1645rn Win32 Version: 1.11.628.1645rn CodeBase: file:///C:/COLDCHAIN/ACLDbUnits.DLLrn----------------------------------------rnSystem.Web.Servicesrn Assembly Version: 2.0.0.0rn Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)rn CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Web.Services/2.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dllrn----------------------------------------rnSystem.Data.SQLitern Assembly Version: 1.0.66.0rn Win32 Version: 1.0.66.0rn CodeBase: file:///C:/COLDCHAIN/System.Data.SQLite.DLLrn----------------------------------------rnSystem.Datarn Assembly Version: 2.0.0.0rn Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)rn CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dllrn----------------------------------------rnSystem.Transactionsrn Assembly Version: 2.0.0.0rn Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)rn CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dllrn----------------------------------------rnSystem.EnterpriseServicesrn Assembly Version: 2.0.0.0rn Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)rn CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dllrn----------------------------------------rn0r-gvosarn Assembly Version: 1.11.628.1645rn Win32 Version: rn CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dllrn----------------------------------------rnfrw6ax9mrn Assembly Version: 3.11.908.1440rn Win32 Version: rn CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dllrn----------------------------------------rnBSQCommurn Assembly Version: 1.0.4588.29637rn Win32 Version: rn CodeBase: file:///C:/COLDCHAIN/BSQCommu.DLLrn----------------------------------------rnmsvcm80rn Assembly Version: 8.0.50727.4053rn Win32 Version: 8.00.50727.4053rn CodeBase: file:///C:/WINDOWS/WinSxS/x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_e6967989/msvcm80.dllrn----------------------------------------rnSMSPDULibrn Assembly Version: 1.0.0.0rn Win32 Version: 1.0.0.0rn CodeBase: file:///C:/COLDCHAIN/SMSPDULib.DLLrn----------------------------------------rnrn************** JIT Debugging **************rnTo enable just-in-time (JIT) debugging, the .config file for thisrnapplication or computer (machine.config) must have thernjitDebugging value set in the system.windows.forms section.rnThe application must also be compiled with debuggingrnenabled.rnrnFor example:rnrnrn rnrnrnWhen JIT debugging is enabled, any unhandled exceptionrnwill be sent to the JIT debugger registered on the computerrnrather than be handled by this dialog box. 论坛

_beginthreadex :错误提示 存储空间不足,无法处理命令

03-22

[code=C/C++]rn#ifndef _CSTHREAD_H_rn#define _CSTHREAD_H_rn#include rnclass CSThreadrnrnpublic:rn CSThread();rn virtual ~CSThread();rn //create a threadrn void __stdcall StartThread();rn //suspend a threadrn void Suspend();rn //resume a threadrn void Resume();rn //waiting thread statesrn bool Wait( DWORD dwTimeoutMillis = INFINITE) const;rn //set thread priorityrn bool SetPriority(const int cnPriority);rn //get thread priorityrn const int GetPriority();rn //stop threadrn void Stop(unsigned uiRetval= 0);rnprivate:rn HANDLE m_hThread;rn unsigned uiThreadID;rnprivate:rn virtual int Run(void *pV ) = 0;rn static unsigned int __stdcall ThreadFunction( void *pV );rn;rn#endifrnrnrnrn#include "CSThread.h"rn#include rn#include "Macro.h"rnCSThread::CSThread()rnrn m_hThread = INVALID_HANDLE_VALUE;rn uiThreadID = -1;rnrnrnCSThread:: ~CSThread()rnrn SAFE_CLOSEHANDLE(m_hThread);rnrnrnvoid __stdcall CSThread::StartThread()rnrn // Create a new thread.rn uintptr_t uiRes = _beginthreadex( NULL, 0, &ThreadFunction, this, 0, &uiThreadID );rn DWORD dwError = GetLastError();rn if (0 == uiRes)rn rn _trace("_beginthreadex exception!");rn return;rn rn m_hThread = (HANDLE)uiRes;rn return;rnrnrnvoid CSThread::Suspend()rnrn SuspendThread(m_hThread);rnrnrnvoid CSThread::Resume()rnrn ResumeThread(m_hThread);rnrnrnrnbool CSThread::SetPriority(const int cnPriority)rnrn if (!SetThreadPriority(m_hThread,cnPriority))rn rn _trace("ThreadFunction exception!");rn return false;rn rn return true;rnrnrnconst int CSThread::GetPriority()rnrn return GetThreadPriority(m_hThread);rnrnrnbool CSThread::Wait( DWORD dwTimeoutMillis ) constrnrn bool bRes = false;rn DWORD result = ::WaitForSingleObject( m_hThread, dwTimeoutMillis );rn if ( result == WAIT_TIMEOUT )rn rn bRes = false;rn rn else if ( result == WAIT_OBJECT_0 )rn rn bRes = true;rn rn return bRes;rnrnrnunsigned int __stdcall CSThread::ThreadFunction( void *pV )rnrn int nResult = 0;rn CSThread* pThis = (CSThread*)pV;rn if ( pThis )rn rn tryrn rn nResult = pThis->Run(pV);rn rn catch(...)rn rn _trace("ThreadFunction exception!");rn rn rn pThis->Stop(0);rn rnrn rn return nResult;rnrnrnvoid CSThread::Stop(unsigned uiRetval )rnrn _endthreadex(0);rnrnrnrn//testrnclass CThreadTest : public CSThreadrnrnpublic:rn CThreadTest();rn ~CThreadTest();rn int Run(void *pV );rnprivate:rn DWORD m_dwLastTime;rnrn;rnrnCThreadTest::CThreadTest()rnrn m_dwLastTime = 0;rnrnrnCThreadTest::~CThreadTest()rnrnrnrnrnint CThreadTest::Run(void *pV )rnrn DWORD dwCurrentTime =0;rn int i = 0;rn while (i < 5)rn rn dwCurrentTime = GetTickCount();rn if (dwCurrentTime - m_dwLastTime > 1000)rn rn printf("%d\n",dwCurrentTime);rn m_dwLastTime = dwCurrentTime;rn ++i;rn rn rn return 0;rnrnrnint _tmain(int argc, _TCHAR* argv[])rnrn CThreadTest test;rn test.StartThread()rn test.SetPriority(THREAD_PRIORITY_HIGHEST);rn test.Wait();rn return 0;rnrn[/code]rnrn单个去测试是没有问题,但是加到实际项目中就提示这样的错误,请问可能的原因是什么?谢谢 论坛

没有更多推荐了,返回首页