[solved] use command's return

hi to all
how can i use the return of a command executed in a terminal ?
thanks
Last edited by nTia89 (2010-12-30 14:32:34)

Allan wrote:In what language?
bash
sisco311 wrote:http://mywiki.wooledge.org/BashGuide/Te … nditionals
thanks very much is what i was searching !
Last edited by nTia89 (2010-12-30 14:17:22)

Similar Messages

  • Client/server RMI app using Command pattern: return values and exceptions

    I'm developing a client/server java app via RMI. Actually I'm using the cajo framework overtop RMI (any cajo devs/users here?). Anyways, there is a lot of functionality the server needs to expose, all of which is split and encapsulated in manager-type classes that the server has access to. I get the feeling though that bad things will happen to me in my sleep if I just expose instances of the managers, and I really don't like the idea of writing 24682763845 methods that the server needs to individually expose, so instead I'm using the Command pattern (writing 24682763845 individual MyCommand classes is only slightly better). I haven't used the command pattern since school, so maybe I'm missing something, but I'm finding it to be messy. Here's the setup: I've got a public abstract Command which holds information about which user is attempting to execute the command, and when, and lots of public MyCommands extending Command, each with a mandatory execute() method which does the actual dirty work of talking to the model-functionality managers. The server has a command invoker executeCommand(Command cmd) which checks the authenticity of the user prior to executing the command.
    What I'm interested in is return values and exceptions. I'm not sure if these things really fit in with a true command pattern in general, but it sure would be nice to have return values and exceptions, even if only for the sake of error detection.
    First, return values. I'd like each Command to return a result, even if it's just boolean true if nothing went wrong, so in my Command class I have a private Object result with a protected setter, public getter. The idea is, in the execute() method, after doing what needs to be done, setResult(someResult) is called. The invoker on the server, after running acommand.execute() eventually returns acommand.getResult(), which of course is casted by the client into whatever it should be. I don't see a way to do this using generics though, because I don't see a way to have the invoker's return value as anything other than Object. Suggestions? All this means is, if the client were sending a GetUserCommand cmd I'd have to cast like User user = (User)server.executeCommand(cmd), or sending an AssignWidgetToGroup cmd I'd have to cast like Boolean result = (Boolean)server.executeCommand(cmd). I guess that's not too bad, but can this be done better?
    Second, exceptions. I can have the Command's execute() method throw Exception, and the server's invoker method can in turn throw that Exception. Problem is, with a try/catch on the client side, using RMI (or is this just a product of cajo?) ensures that any exception thrown by a remote method will come back as a java.lang.reflect.InvocationTargetException. So for example, if in MyCommand.execute() I throw new MySpecialException, the server's command invoker method will in turn throw the same exception, however the try/catch on the client side will catch InvocationTargetException e. If I do e.getCause().printStackTrace(), THERE be my precious MySpecialException. But how do I catch it? Can it be caught? Nested try/catch won't work, because I can't re-throw the cause of the original exception. For now, instead of throwing exceptions the server is simply returning null if things don't go as planned, meaning on the client side I would do something like if ((result = server.executeCommand(cmd)) == null) { /* deal with it */ } else { /* process result, continue normally */ }.
    So using the command pattern, although doing neat things for me like centralizing access to the server via one command-invoking method which avoids exposing a billion others, and making it easy to log who's running what and when, causes me null-checks, casting, and no obvious way of error-catching. I'd be grateful if anyone can share their thoughts/experiences on what I'm trying to do. I'll post some of my code tomorrow to give things more tangible perspective.

    First of all, thanks for taking the time to read, I know it's long.
    Secondly, pardon me, but I don't see how you've understood that I wasn't going to or didn't want to use exceptions, considering half my post is regarding how I can use exceptions in my situation. My love for exception handling transcends time and space, I assure you, that's why I made this thread.
    Also, you've essentially told me "use exceptions", "use exceptions", and "you can't really use exceptions". Having a nested try/catch anytime I want to catch the real exception does indeed sound terribly weak. Just so I'm on the same page though, how can I catch an exception, and throw the cause?
    try {
    catch (Exception e) {
         Throwable t = e.getCause();
         // now what?
    }Actually, nested try/catches everywhere is not happening, which means I'm probably going to ditch cajo unless there's some way to really throw the proper exception. I must say however that cajo has done everything I've needed up until now.
    Anyways, what I'd like to know is...what's really The Right Way (tm) of putting together this kind of client/server app? I've been thinking that perhaps RMI is not the way to go, and I'm wondering if I should be looking into more of a cross-language RPC solution. I definitely do want to neatly decouple the client from server, and the command pattern did seem to do that, but maybe it's not the best solution.
    Thanks again for your response, ejp, and as always any comments and/or suggestions would be greatly appreciated.

  • How to use addKeyListener in a program running using command prompt

    Does anyone have any idea how to add the addKeyListener to a program running using command prompt.
    Let me explain how the program run.
    The program is start and accept call from other program. But from time to time, I need to issue some command by pressing the keyboard, let say, ESC is closed the program, F1 is showing the stated. F2.... (This is all need to run in the command prompt windows)
    My problem is this program does not have any gui interface, so how can it be added?
    i do it this way
    public void key(){          
    addKeyListener(this);
    But it have compile error.
    mainServerImpl.java:87: cannot resolve symbol
    symbol : method addKeyListener (mainServerImpl)
    location: class mainServerImpl
    addKeyListener(this);
    I did implement KeyListener. But just don't know how to solve this error.
    can anyone tell me how to solve it or point me a source that can help.
    Thank in advance!
    Regards,
    Tai Tan

    Write your own Thread, to do this:
    public class KeyThread extends Thread {
       public void run {
          while(true) {
             int i = System.in.read();
             if(i == 123) {
                break; // to stop the thread
    // in your main:
    Thread keyThread = new KeyThread();
    keyThread.start(); // calls run() of the thread

  • Failed to use command "getElementAttribute" in webDrvier.

    Hi Microsoft guys,
    I have written a practice to learn IEDC webDriver (based on the webdriver C# demo)
    Everything worked ok but failed during using 'getElementAttribute'
    WorkFlow:
    1. open "http://www.bing.com" - passed
    2. find element for "input[name='go']" - passed.
    3. find element attribute "class" for #2 element by using "getElementAttribute" command
    always response will be like
    Response received: {"response":{"sessionId":null,"status":"unknown error","value":"Parsing error"}}
    Q:
    As it is a parsing error, i doubt i write the wrong joson for getElementAttribute
    But i checked the msdn, i don't know where i was wrong.
    Could your guys help to have a check on my code ?
    http://msdn.microsoft.com/en-us/library/ie/dn768404%28v=vs.85%29.aspx
    Source code
               //Execute a "get" command - Navigate to http://bing.com
                const string getCommand = @"
                    ""command"": {
                        ""name"": ""get"",
                        ""parameters"": {
                            ""url"": ""http://www.bing.com""
                        ""sessionId"": ""{sessionId}""
                response = ExecuteCommand(getCommand, strSessionId);
                //"Page Loading Strategies" are not currently supported
                //"get" commands will return immediately and not wait for the page to load
                //The 20-second polling is added to wait for the page to load
                //This issue will be addressed and fixed in the next IEWebDriver release.
                WaitForPageToLoad(20, strSessionId);
                //Execute a "findElement" command - Find the Bing search field
                const string findElementCommand = @"
                    ""command"": {
                        ""name"": ""findElement"",
                        ""parameters"": {
                            ""locator"": ""css selector"",
                            ""value"": ""input[name='go']""
                        ""sessionId"": ""{sessionId}""
                response = ExecuteCommand(findElementCommand, strSessionId);
                //Retrieve the ElementId from the response
                try
                    strElementId = response["response"]["value"]["id"];
                catch (Exception e)
                    HandleError("Exception thrown when trying to access strResponse[\"response\"][\"value\"][\"id\"] from the response.", e);
                const string getAttrCommand = @"
                    ""command"": {
                        ""name"": ""getElementAttribute"",
                        ""parameters"": {
                            ""elementId"": ""{elementId}"",
                            ""name"":""title"",
                        ""sessionId"": ""{sessionId}""
                response = ExecuteCommand(getAttrCommand, strSessionId, strElementId);

    Hi MartinLiao,
    This forum is to discuss HTML, CSS and Javascript programming for IE, I think you are posting on wrong forum. I’m not familiar with WebDriver API, so what I can do is to provide code sample for WebDriver. Please refer to the following link to download it.
    http://code.msdn.microsoft.com/windowsdesktop/Internet-Explorer-02ac106f.
    Thank you for understanding.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Is ther any program similar to Process Monitor(Procmon) to use command line?

    Hi.  I need to find some kinds of program like process monitor in terms of using command line
    there is a little bit restrictions to use ProcMon for exploiting command line.
    well, I tried to find such programs like multimon, yapm and so on..
    They are really good. However I couldn't use command line for them.
    Any guys can solve my problem?
    help me

    I agree, the procmon forum is the best place to ask about this.
    You do have command line options available to you:
    Don't retire TechNet! -
    (Don't give up yet - 12,700+ strong and growing)

  • Which job is taking log Backup of specific database using command?

    In my SQL Server there are around 200 jobs of different databases for backup.
    Which job is taking log Backup of specific database using command?
    Kindly help.
    Thanks

    Hi,
    Its generally a bad design to create different jobs for different databases expecially backup and restore if you create you give specific names to the jobs otherwise it would be difficult for you to track. below query will give you littlt help but if you
    are running a proc to backup log files and that proc is situated in master database it wont help. If you are running SSIS package it wont help
    The column database name will help you in locating the DB name for which job is running
    use msdbgoselect sj.name,
    sj.description,
    jst.database_name,
    sj.date_created,
    sj.date_modified,
    jst.step_name,
    jst.command
    from
    dbo.sysjobs sj
    join
    dbo.sysjobsteps jst
    on
    sj.job_id=jst.job_id
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • Database is not getting shutdown when using command "stopsap all"

    I installed ERP 2005(ECC6.0) using oracle on HP-UX with SID=ER1, The installation was successful, but I am facing two issues now.
    1. When I stop sap using command 'stopsap all' only instances is getting shutdown not the database, I have to Explicitly shutdown the database (oracle).
    rp34-109:er1adm 26> stopsap all
    Checking ER1 Database
    ABAP Database is running
    Stopping the SAP instance DVEBMGS01
    Shutdown-Log is written to /home/er1adm/stopsap_DVEBMGS01.log
    Instance on host rp34-109 stopped
    Waiting for cleanup of resources............................
    Stopping the SAP instance SCS02
    Shutdown-Log is written to /home/er1adm/stopsap_SCS02.log
    Instance on host rp34-109 stopped
    Waiting for cleanup of resources.........
    Database is still running on remote DB server
    Log on to DB server and stop database
    TRANS.LOG
    OCI-call failed with -1=OCI_ERROR                   2066  0.175292
    4 ETW000  [dev trc     ,00000]     SQL error 942: 'ORA-00942: table or view does not exist'
    4 ETW000                                                                              71  0.175363
    4 ETW000  [dbsloci.    ,00000]  *** ERROR => ORA-942 when accessing table SAPUSER
    4 ETW000                                                                             115  0.175478
    4 ETW000  [dev trc     ,00000]     set_ocica() -> OCI or SQL return code 942          50  0.175528
    4 ETW000  [dev trc     ,00000]  Disconnecting from connection 0 ...                  205  0.175733
    4 ETW000  [dev trc     ,00000]  Rolling back transaction ...                         127  0.175860
    4 ETW000  [dev trc     ,00000]  Closing user session (con_hdl=0,svchp=0x80000001010858c0,usrhp=0x8000000101075a70)
    4 ETW000                                                                             272  0.176132
    4 ETW000  [dev trc     ,00000]  Now I'm disconnected from ORACLE                     844  0.176976
    4 ETW000  [dev trc     ,00000]  Try to connect with default password                  42  0.177018
    4 ETW000  [dev trc     ,00000]  Connecting as SAPER1/<pwd>@ER1 on connection 0 (nls_hdl 0) ... (dbsl 700 010307)
    The Second issue that I am facing is with the dbs_ora_schema= SAPSR3,
    but my SID is ER1, it should display SAPER1, can anyone help in changing this.
    I tried changing this in .dbenv_hostname.csh & sh files but changing that I even unable to start sap again

    Hi
    Pls follow the notes 400241,662644.
    If u follow above notes you get the result.
    Feel free to revert back
    Pls provide the points if u get the answer.
    ---venakt.

  • Error for COM routine using application program (return code 40.022)

    Hi,
    When iam loading the data into the DP planning book iam getting the "Error for COM routine using application program (return code 40.022)" error.
    How to rectify this,
    Regards,
    Vignesh

    Hi,
    Thank you for your answers. the problem solved now, i did the consistency check for the Planning Area in the background.
    The COM error occurred coz i was trying to change one KF setting in the active PA in the foreground, and when i did the same in the background it worked..
    Regards,
    Vignesh

  • Alert sound when using Command Cut, Copy

    Hi there
    I have what seems to be a strange but recurring problem on a particular website where I have to edit a lot of text and keywords around. I'm using an Apple Macbook running on 10.7.4, but also regularly use an iMac on 10.5.11, and on both computers whenever I use Command + Cut, Copy or Paste I have to endure my alert sound over and over again.
    I know I could simply mute my volume but it's very frustrating and I'd simply like to know why it's happening.
    I have posted in the forum of the website I'm using and no other Mac users have this problem.
    If it's a Command key problem why is it specific to the website I'm using? The alert sound doesn't happen repeatedly when I'm Command + Cutting, Copying or Pasting in any other application.
    It doesn't seem to be a problem with this website because no other users are reporting this.
    I came across a similar forum discussion here but after running Repair Disk Permissions the problem isn't solved.
    Any ideas would be much appreciated!

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem(s)?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault in Mac OS X 10.7 or later, then you can’t enable the Guest account. The Guest login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    *Note: If FileVault is enabled under Mac OS X 10.7 or later, or if a firmware password is set, you can’t boot in safe mode.
    Test while in safe mode. Same problem(s)?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • M500 Issues with locking up (A TCG Command has returned an error)

    Here's the issue, I have researched this A TCG Command has returned an error problem and it seems it's all related to bitlocker problems and or sleep issues, I have all power saving features off, I do "not" have bit locker enabled or running.The problem lies when doing anything that requires hard drive usage other than simple browsing, it can range from 10x in 5 mins on a game and require force reboots and thats the exact error message in the event viewer at the time of crash everytime, I have crashed hundreds of times, and it's getting to the point to where my SSD isn't even fun to own currently, if any of you guru's on here could help that'd be great. Oh and secure boot is turned off (also read about that) It does it with it on or off, doesn't matter. And I had this problem with the default firmware (m03) and the new firmware (m05) I am also on Windows 8.1 64bit. Here are the logs from the event viewer. A TCG Command has returned an error.Desc: AuthenticateSession
    Param1: 0x1
    Param2: 0x60000001C
    Param3: 0x900000006
    Param4: 0x0
    Status: 0x12
    EnhancedStorage-EhStorTcgDrv
    Opcode : TcgLib
    A TCG Command has returned an error.
    Desc: AuthenticateSession
    Param1: 0x1
    Param2: 0x60000001C
    Param3: 0x900000006
    Param4: 0x0
    Status: 0x1
    EnhancedStorage-EhStorTcgDrv
    Opcode : TcgLib
    Everytime I google "A TCG command has returned an error" the first thing that even comes up in google searches is a slew of M500's with bitlocker problems or sleep / power saving option problems, but I do not have any of those enabled. Thanks in advance.

    For sure the different speeds is the difference between the ASMedia and the Intel ports - http://www.tomshardware.com/reviews/storage-controller-performance-ssd,3540.html
    In general Intel ports are suggested as preferred. Perhaps they are more reliable (I don't have any data for that) and they have more frequent driver support/updates.
    It is hard to tell if it is possible that ASM controller is a contributor to the TCG error messages and/or to system freezes/crashes.
    I think it is worth to note that as far as I know hardware based drive encryption (eDrive type) doesn't work with Intel RST drivers and it works only with inbox MSAHCI driver. That makes me think that the storage driver can affect the way the BitLocker works. 
    What is your Windows 8.1 version, is it Pro or Enterprise? W8.1 Pro or Enterprise clean installation can switch the drive to TCG Opal mode and it is done silently. W8.1 do it happily without user's permission (and in many cases without user's knowledge). So my guess is that after silent switching the drive to TCG Opal mode the OS is using some parts of BitLocker... code/engine/mechanisms perhaps.
    You have notice the crashing only really happens when games are being played. I was wondering that maybe the crashes are not related to TCG errors at all and they are related to some other broken driver rather than TCG thing?
    It is possible this is something a reinstall might fix and I would probably try that. But first I would try to switch drive to Intel driven connector and then check and verify all major drivers installed in the system, including motherboard's BIOS - http://www.asus.com/Motherboards/MAXIMUS_VI_HERO/HelpDesk_Download/
    If that wouldn't help I would probably do as suggested by r0m30.
    4. PSID revert the drive (and possibly secure erase it), set a BIOS password on the drive if your motherboard supports it and reinstall window.
    I think romeo was refering to HDD password. It is little weird but motherboard's manual doesn't mention anything about HDD/Drive/Disk/ATA password. 
    In case the mobo supports Drive/ATA password I would do following:
    - PSID revert the drive 
    - set HDD password
    - clean OS install
    In case it doesn't support ATA password (that would be odd but possible I guess):
    - secure erase the drive 
    - clean OS install
    Drives connected to Intel's ports of course 

  • I get the Save As dialog when trying to Save, whether using Command-S or File menu

    When trying to Save a document, I am presented with the Save As dialog. The file name has a serial number added  to the old file name and the default destination is the Documents file. This happens whether I have tried to save using Command-S or using the Save option in the File menu. This started after I upgraded to Mavericks.

    I checked and the files are not stationery pads, Permissions show me as having read and write authority.
    But, when I  opened the files from the finder, the problem disappears and they saved normally. I then removed the files from the Dock and re-placed them in the Dock via drag and drop. The problem re-appears and changes will not save normally. Not being able to use the Dock is inconvenient but at least there is a workaround. Thanks for your help! Before declaring victory, I'd like to watch it for a while for other quirks.

  • Adding key figures using commands in Web Application Designer?

    Hello, all.
    I have a query the contains several key figures.  From that query, I created a query view in which only one of the key figures is displayed.  I'm using this query view for one of the data providers in a web template.  In Web Applicaiton Designer, I would like to be able to hide the key figure from the data provider and show a different one.  How can I accomplish this using the built-in commands?
    I know I can hide all key figures using the CLEAR_SELECTION_STATE command, but I can't figure out how to use a command such as SET_SELECTION_STATE_SIMPLE to show a different key figure.  Any help would be great!  Thanks.

    I've tried that using the GUI to configure the command, but WAD crashes when I try to open the window where I choose the member name.  The error says:
    "4A6DM1A4LTXPJKA1BA3LD9TTD is not a valid characteristic for InfoProvider MQM_M01."
    I also tried entering the commands as you suggested in the XHTML editor, but that resulted in an error when I tried to execute the command.
    Maybe I can do what I'm trying to do using some method other than changing key figures.  Basically all I want do is change the date range of the data shown using offsets.
    The key figures that I'm trying to add and remove are restricted in Query Designer to different date ranges.  These date ranges use offsets to set the restriction.  For example, one key figure is restricted to display values for only the last 7 days and I'm trying to replace it with a key figure that's restricted to the last 14 days.
    If I knew how to set a filter with offsets using commands in WAD, then I'd use that method, instead.  Any suggestions would be appreciated.

  • Safari 7.0.2 Location bar will not stay open and I must use command L each time to with go back or use the address bar

    Safari 7.2.2 loction bar wil not stay open and I must use command L to either go back or to use the address bar

    View > Show Toolbar

  • When creating a new window in safari, using command T, the marker have not activated the search field. It means you have to click there every time. Changed after upgrading to Mavericks. Anyone knows how to change this?

    When creating a new window in safari, using command T, the marker have not activated the search field. It means you have to click there every time. Changed after upgrading to Mavericks. Anyone knows how to change this?

    Yes, you can do something like that. What you would do is create a button for each image and then hide them. When I do this type of thing I place all of the buttons on a template page and then hide the template.
    You can then use JavaScript to copy the icon from any of the hidden buttons to the main button that you've set up to display the image. For example, suppose you set up 10 buttons named b1, b2, b3, ...b10. The code to copy the icon from one of them to the button used to display the image (b0) would be something like this:
    // Get the icon from the b3 button
    var oIcon = getField("b3").buttonGetIcon();
    // Get  reference to the b0 button
    var f = getField("b0");
    // Set the icon of the b0 button to the icon retrieved from the hidden button
    f.buttonSetIcon(oIcon);
    // Show the b0 button
    f.display = display.visible;
    This code would go in the Mouse Up event of the smaller button.

  • How to print a specific page from a given PDF document, using command line, please?

    Hello,
    I need your advise, please. My customer requires to print a specfic page from a pdf document they receive, using command line or 3rd party solution.
    Anything you can advise, please? I have seen AcroRD32.exe options, but can only print the whole document.
    Kind Regards

    Not sure if there are any examples. The Acrobat SDK is a must, but it is best treated as documentation to study rather than examples to copy. The examples only illustrate a tiny fraction of the capabiliies.
    (One other note: the solution must involve the client owning Acrobat; Acrobat is not for server use).

Maybe you are looking for

  • Attachmentbuttons are not active in Hotmail using Firefox 8.0, how to solve?

    Hello, I'm using Firefox since the very first day and I'm really happy about it. But since a few releases I'm experiencing problems with Hotmail.com. I just can't attach files to my e-mails, the buttons are there but they're not working. If I want to

  • Screen Modification i Table Control

    Hi all,    we have a requirement on modifying the screen field attributes for a table control.   scenario : f1  f2   f3   f4 now when the user enters the input for field f1 a pop-up  appears wherein you will have to make a selection. the selected one

  • Edge Animate will not install.

    I am receiving an error message when trying to install Edge Animate.  "A beta version of this product exists on the computer.  Please quit and uninstall that version before continuing; contact support."  I have uninstalled the beta version and no ver

  • Will OS 10.4.11 update run classic?

    Hello, I'd like to know if I update from 10.4.6 to 10.4.11, will I still be able to run Classic? Thank you for the information.

  • Frustrated with iWeb 1.0.1

    Like others I'm finding that my iWeb website does not properly update. After making the same changes to my site, I publish them and repeatedly the results are poor. Changes frequently don't migrate to the site and there are lots of little question ma