Results 1 to 6 of 6

Thread: How to not diplay shell script lines running

  1. #1
    Join Date
    May 2011
    Location
    Golden, CO
    Beans
    90
    Distro
    Ubuntu 12.04 Precise Pangolin

    How to not diplay shell script lines running

    So I created a small bash script to consolidate some files across a couple different unix machines, what they are is irrelevant. Script works fine.

    I have a batch file on a PC that remotely executes this script, again, no hiccups in the process. However in batch scripting, by running the script in null mode I can have the script only display specific lines of operation by ending that line of code with ">&2"

    Is there a way in bash scripting to do the same? The consolidation script, runs through the multiple machines getting files and bringing them to a single location... but it outputs every single operation to the terminal.

    I'd like it to ONLY display the line in the script that prompts for a an SFTP connection password, and that's it...

    Possible?
    Last edited by sectshun8; January 24th, 2013 at 09:56 AM.
    Ubuntu 12.04 for personal use
    Solaris 9, 10 and Red Hat Ent 5 @ work

  2. #2
    Join Date
    May 2006
    Location
    Boston
    Beans
    1,918
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to not diplay shell script lines running

    Quote Originally Posted by sectshun8 View Post
    So I created a small bash script to consolidate some files across a couple different unix machines, what they are is irrelevant. Script works fine.

    I have a batch file on a PC that remotely executes this script, again, no hiccups in the process. However in batch scripting, by running the script in null mode I can have the script only display specific lines of operation by ending that line of code with ">&2"

    Is there a way in bash scripting to do the same? The consolidation script, runs through the multiple machines getting files and bringing them to a single location... but it outputs every single operation to the terminal.

    I'd like it to ONLY display the line in the script that prompts for a an SFTP connection password, and that's it...

    Possible?
    Code:
    ./myscript.sh 1>/dev/null

    blog
    Donations BTC : 12FwoB7uAM5FnweykpR1AEEDVFaTLTYFkS
    DOUBLEPLUSGOOD!!

  3. #3
    Join Date
    May 2011
    Location
    Golden, CO
    Beans
    90
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to not diplay shell script lines running

    Thanks for that... the exact syntax did not work for me, but it put me in the right direction. Running it locally from the unix machine works exactly as I want... but now writing the command file for the PC batch file to execute this script remotely is going to be a pain.

    Currently in the command file, I use the line to out to the command file
    Code:
    echo bash xf1.sh>>%xf%
    Unfortunately, the following does not work with that. The ">" and "&" characters don't transfer very well..
    Code:
    echo bash xf1.sh > & null.txt>>%xf%
    Last edited by sectshun8; January 24th, 2013 at 11:14 AM.
    Ubuntu 12.04 for personal use
    Solaris 9, 10 and Red Hat Ent 5 @ work

  4. #4
    Join Date
    May 2011
    Location
    Golden, CO
    Beans
    90
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to not diplay shell script lines running

    Google is my friend, haha. batch scripting uses "^" as escape character... so the working code is:
    Code:
    echo bash xf1.sh ^> ^& null.txt>>%xf%
    Ubuntu 12.04 for personal use
    Solaris 9, 10 and Red Hat Ent 5 @ work

  5. #5
    Join Date
    May 2011
    Location
    Golden, CO
    Beans
    90
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to not diplay shell script lines running

    The new script is working just as I hoped it would. However a couple of end users note that after the remote bash script prompts for the SFTP password, and it is entered, all that remains is a blinking cursor, with no way of telling if the program is running until the remote script finishes and the local script continues.

    Is there a way in the bash script to single out a line to echo into the terminal to "Please wait, remotes script in progress..." even when the script is outputting to null, or in my case a temp text file?

    As I stated earlier, I know in batch scripting, running the script in "null mode", you can override the null output by putting a >&2 at the end of the line, this will allow that given line of code to be displayed in the terminal regardless. Surely I can do this in bash?
    Last edited by sectshun8; January 25th, 2013 at 11:20 AM.
    Ubuntu 12.04 for personal use
    Solaris 9, 10 and Red Hat Ent 5 @ work

  6. #6
    Join Date
    Jun 2010
    Location
    N. Wisconsin
    Beans
    Hidden!

    Re: How to not diplay shell script lines running

    Check Multiple Redirections section:

    http://wiki.bash-hackers.org/syntax/redirection

    May give a hint.
    AMD PII X6 @ 3.63 GHz - 16 GB DDR3 (1600 No OC) - ASUS Crosshair V Formula
    SB X-Fi 2 Sound (8ch) - Intel 10/100/1000 Gigabit Ethernet - Win 8 Pro. x64
    AMD R HD 7950 (SAPPHIRE) - WD CG 500GB - Thermaltake Frio CPU Cooler

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •