Bash: Use command output as argument for next command in pipe

I'm trying to do this:
tail -f /var/logfile | grep -C 0 text | mail -s "OUTPUT OF GREP" [email protected]
How can I do this?

Haven't tested it but try
mail -s $(tail -f /var/logfile | grep -C 0 text) [email protected]
Edit: Are you sure it will work with 'tail -f'?
Seems that the subject can't contain certain characters:
[karol@black ~]$ mail -s $(tail /var/log/kernel.log | grep -C 0 detected) [email protected]
18:05:11 contains invalid character ':'
kernel: contains invalid character ':'
[ contains invalid character '['
8.433910] contains invalid character ']'
4-0:1.0: contains invalid character ':'
^C
How will you escape multiple newlines?
Last edited by karol (2011-05-20 15:20:07)

Similar Messages

  • Can't we use function to derive value for NEXT clause in MV ?

    Hi Friends,
    I have a requirement like below
    I need to derive the schedule (Value for NEXT clause in the create MV command) for a MV to run it
    e.g., Value from a date column : 03-JUL-2012 10:00 AM, VALUE for NEXT clause in CREATE MV statement should be 03-JUL-2012 04:45 AM (It is -5.45 hrs from the above date column value )
    So I wrote a function (GET_DATE) to derive schedule for NEXT clause and tried to call it from NEXT caluse, but it is giving error message as mentioned below
    ORA-04044: procedure, function, package, or type is not allowed here
    CREATE MATERIALIZED VIEW child_mv
    PARALLEL 16
    INITRANS 16
    STORAGE (
    FREELISTS 16
    FREELIST GROUPS 4
    BUILD IMMEDIATE
    REFRESH COMPLETE
    NEXT GET_DATE('PARENT_MV')
    AS
    SELECT * from xxmdme_party_stage where rownum<101;
    Could you please help to give some light on how this can be done ?

    942661 wrote:
    Hi Friends,
    I have a requirement like below
    I need to derive the schedule (Value for NEXT clause in the create MV command) for a MV to run it
    e.g., Value from a date column : 03-JUL-2012 10:00 AM, VALUE for NEXT clause in CREATE MV statement should be 03-JUL-2012 04:45 AM (It is -5.45 hrs from the above date column value )
    So I wrote a function (GET_DATE) to derive schedule for NEXT clause and tried to call it from NEXT caluse, but it is giving error message as mentioned below
    ORA-04044: procedure, function, package, or type is not allowed here
    CREATE MATERIALIZED VIEW child_mv
    PARALLEL 16
    INITRANS 16
    STORAGE (
    FREELISTS 16
    FREELIST GROUPS 4
    BUILD IMMEDIATE
    REFRESH COMPLETE
    NEXT GET_DATE('PARENT_MV')
    AS
    SELECT * from xxmdme_party_stage where rownum<101;
    Could you please help to give some light on how this can be done ?you must (ab)use EXECUTE IMMEDIATE

  • XSQL query output as parameter for next xsql query

    Hi,
    Is it possible to use the output of one xsql query as input parameter for the next xsql query in the same file. I am trying to retreive an id from the query and use it in the next one. I cannot combine all the queries into one, since I intend to make the first query a database function that returns the id I am looking for. I am looking for something like this
    <xsql:query>
    select '1000' as myid
    from dual
    </xsql:query>
    <xsql:query>
    select add1,ro1
    from table1
    where id = {@myid}
    </xsql>
    I need the id returned by the first query to be used in the second one. Eventually my first query will be a stored procedure that validates the users rights and on sucess return the following tag <myid> 1000 <myid>.
    Please let me know , how I can achieve my goal of validating a user's priveleges and then executing the second query.
    Thanks
    Padmaja

    Hi ,
    Thanks for the response.This works if the first query is a select .
    If the first query was a call to a db procedure that returned the <myid>100<myid> would this still work?
    <xsql:set-page-param name="myid">
    <xsql:include-owa>
    xyz;
    </xsql:include-owa>
    </xsql:set-page-param>
    <xsql:include-param name="myid"/>
    <xsql:query>
    select name from mytable where id={@myid}
    </xsql:query>
    I have to use include-owa as the db procedure xyz does some cookie validations and then returns an id based on that. The procedure xyz returns an xml tag of form <myid>100<myid>
    This does not work as the value of myid is not available to the second query.
    Thanks
    Padmaja

  • BAPI_GOODSMVT_CREATE used and output shows locked for different item

    Hi experts,
    The program is using BAPI " BAPI_GOODSMVT_CREATE"  in a loop ( that is single item everytime )
    and then BAPI TRANSACTION  COMMIT has used ( with no parameters) .  When we are selecting more than one item for the same material , for the first item its get posted successfully but for other it shows error that "ponumber/itemnumber is locked by the user"  .
    Now I guess this error is due to the system load  as when I am running this in debugging mode all the items get posted successfully . So I think we need to put some time delay between two items.
    Please provide me some solutions and ways to resolve it  asap.

    Hi Anindita,
    After calling BAPI_GOODSMVT_CREATE , if the return table is empty, you can set the wait parameter in the FM  BAPI_TRANSACTION_COMMIT as below. This iwill do the trick.
            CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
             EXPORTING
               WAIT          = 'X'
            IMPORTING
              RETURN        =

  • Internet Explorer's forward/backward for next/previous image

    In addition to right/left arrow to move to next/previous image I would like LR team to add this keyboard shortcut:
    Use Internet Explorer's forward for next image.
    Use Internet Explorer's backward for previous image.
    Here is the reason. I have ViewSonic mouse with five buttons. Extra two buttons I use for forward/backward command within Internet Explorer. It would be nice if the same two extra buttons I could use in LR.
    At the moment I have the two extra buttons programmed to function as right/left arrow. That allows me to use them to go next/previous image in LR. In order to use them as a forward/backward command within IE I have to press Alt key.
    It would be nice if LR team could add IE forward/backward to the list of keyboard shortcuts.
    Best regards,
    Ivan Kmecko

    This is a function of the mouse driver...you should be able to configure settings based on the current application so LR and IE can use the same keys but it'll mean different things in each app.

  • Can you use information obtained in the report to use as output?

    I am wondering if in XI R2 or 2008 you can use infomation obtained in the report generation to use in output parameters?   For example, if my results come back with email addresses, can I then use them to email to?

    There are several export options.  But how about this solution:
    Insert a text object on the detail line with the text "E-mail: ".  Then drag the data field of the company/person's name and drop it in the text at the end.
    Then, right-click the text, and select "Format Text...".  Then click the Hyperlink tab and select "An EMail Address".  Below, for the e-mail address, it says "mailto:" but you don't want a static address.  So click on the formula button on the right.  For the formula, enter "mailto:" +
    When you run the report, you'll see "E-Mail: John Doe" but when you click on it, it'll open a mail message window with the address as the recipient.  (The names of the victims in this example have been changed, to protect the innocent   )
    I'm sure there are several other ways to accomplish your goal, but without more info on your situation, I can only guess that this is the best one.

  • I want to disable 'Spotlight' for repairing my disk "Macintosh HD" , but somehow the command 'sudo mdutil -a -i off' does not work in 'Terminal'. I get result as ' bash: sudo: command not found' .I am using OS 10.10.  Please help.

    I want to disable 'Spotlight' for repairing my disk "Macintosh HD" , but somehow the command 'sudo mdutil -a -i off' does not work in 'Terminal'. I get result as ' bash: sudo: command not found' .I am using OS 10.10.  Please help.

    It appears that you may not have a properly installed OS X system.
    You must be connected to the Internet to reinstall OS X.
    In the menu bar, choose Apple menu > Restart. Once your Mac restarts (and the gray screen appears), hold down the Command (⌘) and R keys.
    Select “Disk Utility,” and then click Continue.
    Select your startup disk from the list on the left, and then Repair Disk.
    After disk is repaired, select Reinstall OS X, then click Continue.
    Follow the onscreen instructions. In the pane where you select a disk, select your current OS X disk

  • Script for using layer name in Save for Web command

    I am using the Save for Web  command (Illustrator CS2) to export layers to CSS so that each layer is  saved as a different jpg.  The only issue I have is that I want the  layer name to be part of the file name, but layer name is not an option  when I look at the "Edit Output settings" dialog for saving files.  Is  there anyway I can do this? I do not have experience writing or working with scripts.
    For example. My fiel name is flower.ai.  I will have 20  different layers (each containing a different color of the same image)  and want the exported file to be flower-scarlet.jpg,  flower-cranberry,jpg, etc. Right now I am looking at renaming all the  files manually, but as I am creating 40 images per product on my website, this will be very time consuming.
    Thanks in advance
    Christine

    Btw.. to make it work for JPGs, change the PNG options to the following:
    var options = new ExportOptionsJPEG();
            options.antiAliasing = false;
            options.optimization = false;
            options.artBoardClipping = true;
            options.qualitySetting = 100; // value of 0 to 100, 60 is medium, 100 is perfect
            options.blurAmount = 0;
            options.verticalScale = 100;
            options.horizontalScale = 100;

  • Could not execute auto check for display colors using command /usr/

    I am trying to Install Oracle 10g R2 on Solaris X86 32 bit
    I am connecting to system from my windows vista laptop through putty... I get the following error...
    $ ./runInstaller
    Starting Oracle Universal Installer...
    Checking installer requirements...
    Checking operating system version: must be 5.10. Actual 5.10
    Passed
    Checking Temp space: must be greater than 250 MB. Actual 1214 MB Passed
    Checking swap space: must be greater than 500 MB. Actual 1799 MB Passed
    Checking monitor: must be configured to display at least 256 colors
    >>> Could not execute auto check for display colors using command /usr/openw
    Some requirement checks failed. You must fulfill these requirements before
    continuing with the installation,at which time they will be rechecked.
    Continue? (y/n) [n] n
    User Selected: No
    Exiting Oracle Universal Installer, log for this session can be found at /tmp/Or
    I have done the following:-
    # DISPLAY=192.168.1.133:0.0; export DISPLAY
    # echo $DISPLAY
    192.168.1.133:0.0
    # xhost+
    xhost+: not found
    # xclock
    xclock: not found
    I know that I have to do the following:-
    1. Install SUNWxwplt package ========> Is already Installed
    2. Set DISPLAY variable
    3. Execute xhost + on target (set in DISPLAY) computer
    # pkginfo -i SUNWxwplt
    system SUNWxwplt X Window System platform software
    Some sites claim xming and some xwindows etc.... Plz give me a step by step instruction as how to overcome this..
    bash-3.00# /usr/openwin/bin/xclock
    Error: Can't open display:
    bash-3.00# DISPLAY=192.168.1.133:0.0; export DISPLAY; echo DISPLAY
    DISPLAY
    bash-3.00# echo $DISPLAY
    192.168.1.133:0.0
    bash-3.00# /usr/openwin/bin/xclock
    Error: Can't open display: 192.168.1.133:0.0
    bash-3.00# pwd
    bash-3.00# find . -name xhost
    ./usr/openwin/bin/xhost
    ^C
    bash-3.00# /usr/openwin/bin/xhost +
    /usr/openwin/bin/xhost: unable to open display "192.168.1.133:0.0"
    bash-3.00#
    # echo $PATH
    /usr/sbin:/usr/bin
    I have also gone through the below ... but was not of much help
    Unable to execute runInstaller: Check if the DISPLAY variable is set
    Plz help
    Edited by: [email protected] on Feb 11, 2009 5:16 AM

    bash-3.00# echo $SHELL
    /sbin/sh
    bash-3.00# echo $DISPLAY
    bash-3.00# DISPLAY=192.168.1.133:0.0;export DISPLAY
    bash-3.00# echo $DISPLAY
    192.168.1.133:0.0
    bash-3.00# /usr/openwin/bin/xclock
    Error: Can't open display: 192.168.1.133:0.0
    bash-3.00# man xclock
    No manual entry for xclock.
    bash-3.00# /usr/openwin/bin/xhost +
    /usr/openwin/bin/xhost: unable to open display "192.168.1.133:0.0"
    bash-3.00#

  • ADDRESS output as an argument for AVERAGE help.

    I have column A with ~10,000 entries. I would like to know the average of 100 consecutive entries and use a slider control to supply the starting row number of the 100 rows.
    I tried to start by using
    =ADDRESS(D4,1,4) where the value of D4 is the determined by the slider control and,
    =ADDRESS(D4+100,1,4) in an adjacent cell to give the ending value for the AVERAGE function.
    I think the output of the ADDRESS function is seen as a string rather than an argument for the average function. Is this true? Does anyone have any slick ideas for creating a sliding averager?
    Thanks for any thoughts.

    In D3 I stored the number of rows to average
    In D4 I stored the first row to average.
    In D5 the formula is:
    =AVERAGE(OFFSET($A$1,D$4,0,IF(D$3+D$4>ROWS($A),ROWS($A)-$D$4,$D$3)))
    If there are D3 rows available starting from row D4 it averages these rows
    If there are no such rows, it averages only the existing ones.
    I didn't tested the case where D4 is greater than the number of existing rows.
    Yvan KOENIG (from FRANCE dimanche 11 janvier 2009 11:58:15)

  • Setting Command Line Arguments for my Class

    HI,
    How do I set the command line arguments for my debug class. For example , I would like my user to type :
    java Debug -LEVEL1
    What should I do to implement this behaviour.
    Thanks in advance...

         public static void main (String[] args){
              if(args.length > 0){
                   int j = 0;
                   BMsearch search = new BMsearch();
                   try{
                        while (j < args.length){
                             if(args[j].equalsIgnoreCase(ONE_PATERN)){
                                  search.addPaternForSearch(args[j+1]);
                                  j = j+2;
                             else if (args[j].equalsIgnoreCase(PATERNLIST)){
                                  j++;
                                  while( ! (args[j].startsWith("-")) ){
                                       search.addPaternForSearch(args[j]);
                                       j++;
                                  }//end while
                             else if (args[j].equalsIgnoreCase(PATERNFILE)){
                                  j++;
                                  search.readPaternFile(args[j]);
                                  j++;
                             else if(args[j].equalsIgnoreCase(MATCH_H)){
                                  search.heuristic = MATCH_HEURISTIC;
                                  j++;
                             else if(args[j].equalsIgnoreCase(MATCH_H2)){
                                  search.heuristic = MATCH_HEURISTIC_TWO;
                                  j++;
                             else if(args[j].equalsIgnoreCase(OCC_H)){
                                  search.heuristic = OCC_HEURISTIC;
                                  j++;
                             else if(args[j].equalsIgnoreCase(COMB_H)){
                                  search.heuristic = COMBINED_HEURISTIC;
                                  j++;
                             else if(args[j].equalsIgnoreCase(JAVA_S)){
                                  search.heuristic = JAVA_NATIVE;
                                  j++;
                             else if(args[j].equalsIgnoreCase(TEXTFILE)){
                                  j++;
                                  search.readFileIn(args[j]);
                                  j++;
                             else if(args[j].equalsIgnoreCase(TEXTURL)){
                                  j++;
                                  search.readURLFileIn(args[j]);
                                  j++;
                             else if(args[j].equalsIgnoreCase(STOPatFIRST)){
                                  search.searchall = false;
                                  j++;
                             else if(args[j].equalsIgnoreCase(STOPatLAST)){
                                  search.searchall = true;
                                  j++;
                             else if(args[j].equalsIgnoreCase(VERBOSE)){
                                  search.verbose = true;
                                  j++;
                             else if(args[j].equalsIgnoreCase("-h") || args[j].equalsIgnoreCase("-help")){
                                  printHelp();
                                  Start = false;
                                  break;
                             else{
                                  System.out.println(" Error while parsing Parameter. ");
                                  System.out.println(" type java BMsearch -help for all Options");
                                  Start = false;
                                  break;
                        }// end outer while
                   catch(Exception e){
                        System.out.println(" Error while parsing Parameter. ");
                        System.out.println(" type java BMsearch -help for all Options");
                        Start = false;
                        j = args.length;
                   if(Start){
                        if(search.verbose)System.out.println(" Parameter parsed, beginning with search ...");
                             search.starttimeTotal = System.currentTimeMillis();
                        search.search();
                        search.stoptimeTotal = System.currentTimeMillis();
                        System.out.println(" Whole search took:  " + (search.stoptimeTotal - search.starttimeTotal) + " milliseconds.(Brutto) ");
              else{
                   System.out.println(" Error while parsing Parameter. ");
                   System.out.println(" type java BMsearch -help for all Options");
         }//end MAINThis is takem from one of my command line classe (a Boyer Moore Pattern-Matching application from an exercise). I don't know if this is the best way, but thats what I have done there for passing some arguments, where the order of them isn't pre-given (you can pass the params in the order you want).
    The CAPITAL vars are pre-defined final Strings holding the param-names, e.g.
    public static final String ONE_PATERN = "-p";
    public static final String PATERNLIST = "-plist";
    public static final String PATERNFILE = "-pfile";Another trick sometimes used in Linux/Unix, if you have only false/true combinations, are numbers from pow 2 (2,4,8,16). In C they are used because of the binary representation, but it has some benefits. E.g. a value of 2 (0010) and another true set on 4 (0100) results binary in 6 (0110), so you can mix parameters in only one value, and with a byte - array you could check, if the flag for a given param is set. But this way is a little tricky for the end-user.

  • How to use command promt for calling a java programe

    Hi
    i am using command promt to call my class CreateProdcut
    i am trying to call cmd.exe and then calling a class with argument *"java CreateProduct -----argument----"*
    Following is the code i am using to call cmd.exe as a seprate process
    Problem :-  I am not able to see command promt and called class o/p
    import java.io.*;
    public class ExecCreateProduct{
         public static void main(String args[]) throws IOException, java.lang.InterruptedException{
              Runtime runtime = Runtime.getRuntime();
                             Process pr = runtime.exec ("cmd /c"+"java "+"CreateProduct "+"Hello World"+"HHH");
               try {
               String line;
               BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                    while ((line = input.readLine()) != null) {
                   System.out.println(line);
                   input.close();
                   } catch (Exception err) {   
                        err.printStackTrace();
              int exitVal = pr.waitFor();
            System.out.println("Exited with error code "+exitVal);
    }Edited by: rahul_p on Jun 9, 2009 2:58 AM

    do it like this it works for me :)
    try{
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("java CreateProduct -----argument-----");
    InputStream stderr = proc.getErrorStream();
    InputStreamReader isr = new InputStreamReader(stderr);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ( (line = br.readLine()) != null)System.out.println(line);
    int exitVal = proc.waitFor();
    exitVal!=0?System.out.println("Error"):System.out.println("success");
    catch(Exception e){
    System.ourt.println(e);
    }

  • How to use the Output clause for the updated statment

    How to use the output clause for the below update stament,
    DECLARE @MyTableVar table(
        sname int NOT NULL)
    update A set stat ='USED' 
    from (select top 1 * from #A 
    where stat='AVAILABLE' order by sno)A
    Output inserted.sname
    INTO @MyTableVar;
    SELECT sname
    FROM @MyTableVar;
    Here am getting one error incorrect syntax near Output
    i want to return the updated value from output clause

    see
    http://blogs.msdn.com/b/sqltips/archive/2005/06/13/output-clause.aspx
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Is there anyway to have an application use the output for Alerts/Sound Effects?

    I am trying to set some applications to use the output designated for the System Alerts and Sound Effects, while other applications continue to use the regular Output?  I am using the Audio MIDI Utility with Aggregate/Multiple Outputs.

    An action can specify the resources that it needs, which will trigger alerts if they are not there.  Assuming that the system resources are there, you can include actions in an application bundle - see the Installing Actions section of the Automator Programming Guide.

  • After i have downloaded an album from iCloud to my new macbook pro. Itunes will only play one song at a time. If i hit the fast forward or back button will not do anything. I have to use the mouse to hit the next tidal in the album then hit play for it

    after i have downloaded an album from iCloud to my new macbook pro. Itunes will only play one song at a time. If i hit the fast forward or back button will not do anything. I have to use the mouse to hit the next tidal in the album then hit play for it to play the next song. Or put it in the UP NEXT.

    First, make sure these items have checkmarks next to their names in iTunes. Continuous playback only works on checked items. Itunes will play all checked items in a list whether or not they're from the same album.
    If you see that nothing in your library is checked and you want to check everything, hold down Ctrl while checking an item. This checks everything.
    Next, fixing the "1 of 1" problem is easily. Select all the tracks that make up the book/album. Let's say there are 15. Press Ctrl-I. Doublecheck that the album box is filled in with the name of the book, and if not, type it there. Enter "15" in the box for the total number of tracks. Click OK. Now all the items should be "1 of 15," "2 of 15," and so on.

Maybe you are looking for

  • When I restart, previous tabs & websites open. I have selected open in new page in options this does not work

    When I start my computer and open Firefox, all the tabs from the previous session open. For now, I have to return each session to my home page (Google) prior to closing to prevent this from occuring. I have selected "When Firefox starts show my home

  • Home Sync errors with Chrome files

    Recently a bunch of users in our office have been getting constant Home Sync errors, most commonly with Google Chrome files. File Sync opens and lists a number of errors syncing files including: Favicons History History Index 2012-02 History index 20

  • Balance Decrease = Score Decrease?

    So, I got an alert today which says that my credit card balance decreased by 55% which lead to a 6 pt drop in my score. Does this sound right? If I am paying off my credit card balance, why is my score dropping instead of increasing? Please hep me un

  • Ich habe Reader Version 11.0.06 installiert; Menu nur in Englisch

    Ich habe Reader Version 11.0.06 in deutsch installiert, Menue nur in Englisch. Windows7 Service Pack 1 64Bit Office 2013HB Reader mehrmals deinstalliert Rechner neu gestartet und wieder installiert. Kein Erfolg

  • Why isn't PSD backwards compatibility to previous versions?

    I already have two licenses - one for CS4 suite on one machine and CS5 suite on another.  Some of my CS5 files are not backwards compatible - not recognized in CS4.  I have spent a lot of money - and you release new versions practically every year.