Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6555521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:49:49+00:00 2026-05-25T12:49:49+00:00

I have a script named password-for-object which I normally run like that: $ password-for-object

  • 0

I have a script named password-for-object which I normally run like that:

$ password-for-object example.com
sOtzC0UY1K3EDYp8a6ltfA

I.e. it does an intricate hash calculation and outputs a password that I should use when accessing an object (for example, website) named example.com. I’ll just double click the whole password, it gets copied into my buffer and I’ll paste it into the form.

I’ve also learnt a trick on how to use such a script without making my password visible:

$ password-for-object example.com | xclip

This way output of a script ends up in X’s primary buffer and I can insert it right into password field in the form and it’s not shown on the screen.

The only problem with this way is that password-for-object outputs a string with trailing newline and thus “xclip” always catches up an extra symbol – this newline. If I omit output of newline in password-for-object, then I’ll end up with messed up string without xclip, i.e. when I’m just putting it on the stdout. I use 2 shells: zsh and bash, and I’ll get the following in zsh (note the extra % sign):

$ password-for-object example.com
sOtzC0UY1K3EDYp8a6ltfA%
$

Or the following in bash (note that prompt would be started on the same line):

$ password-for-object example.com
sOtzC0UY1K3EDYp8a6ltfA$

Any ideas on how to work around this issue? Is it possible to modify the script in a way so it will detect that xclip is in the pipeline and only output newline if it isn’t?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:49:50+00:00Added an answer on May 25, 2026 at 12:49 pm

    If you change password-for-object so that it doesn’t output a newline, you can call it with a script like:

    #!/bin/bash
    password-for-object "$1"
    if [ -t 1 ]
    then
        echo
    fi
    

    The -t condition is described in the bash manual as:

    -t fd

    True if file descriptor fd is open and refers to a terminal.

    See the following question:

    • How to detect if my shell script is running through a pipe?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example),
i have the following simple script <input class=input type=text name=password style=color: #797272; value= <?php
I have a compiled .NET assembly with a specific resource file embedded (named 'Script.xml').
For simplicity, i have the following file named test.jsp: <script language=javascript> alert(a$b.replace(/\$/g,k)); </script> I
I have a script that takes a table name and generates a control file
I have a PHP script (running on a Linux server) that ouputs the names
I have created a script that reads from a CSV (or other dataset, but
I have another script that I can't figure out what is wrong with it.
I have a login screen with username and password credentials that are validated throught
I have a Perl CGI script that creates a login screen, i.e. user name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.