redirect,zsh,xargs , xargs: exec command with prompt


xargs: exec command with prompt

Question:

Tag: redirect,zsh,xargs

I'm trying to do the following with xargs

pacman -Q | grep xf86-video | awk '{print $1}' | xargs pacman -R to remove all xf86-video-* driver on my machine. To make the question more clear, here is the output of pacman -Q | grep xf86-video | awk '{print $1}':

xf86-video-ark
xf86-video-ati
xf86-video-dummy
xf86-video-fbdev
xf86-video-glint
xf86-video-i128
xf86-video-intel
xf86-video-mach64
xf86-video-neomagic
xf86-video-nouveau
....

when I redirect the result to xargs, the output looks like this:

xargs result

The point is, the command which xargs is about to execute need user to do some additional input(as you can see it needs a Yes/No), but xargs automatically add a unknown symbol #, and exit, which causes my purpose UNACHIEVED.

WHY xargs would do this or, what can I do to use xargs for command with prompt?


Answer:

You can use

xargs -a <(pacman -Q | awk '/xf86-video/{print $1}') pacman -R

Explanation:

Without further arguments xargs does not work with interactive (command line) applications.

The reason for that is, that by defaultxargs gets its input from stdin but interactive applications also expect input from stdin. To prevent the applications from grabbing input that is intended for xargs, xargs redirects stdin from /dev/null for the applications it runs. This leads to the application just receiving an EOF. (Running just pacman -R SOMEPACKAGE and pressing Ctrl+D has the same effect).

To get xargs to work with interactive commands you have to use the --arg-file=FILE argument (short -a FILE). This tells xargs to get the arguments from FILE. This also leaves stdin unchanged.

So you could either put your package list into a temporary file

pacman -Q | awk '/xf86-video/{print $1}' > /tmp/packagelist
xargs -a /tmp/packagelist pacman -R
rm /tmp/packagelist

or you can use zsh's process substitution mechanism <(list). When executing a line with <(list), <(list) is replaced by a filename from where the output of list can be read.

xargs -a <(pacman -Q | awk '/xf86-video/{print $1}') pacman -R

The single # you get is not from xargs but from zsh itself. If the shell options PROMPT_CR and PROMPT_SP are set (which both are by default) zsh tries to preserve partial lines, that is lines that did not end with a newline. To signify that such a line has been preserved zsh prints an inverse+bold character at the end of that line, by default % for normal users and # for root.


Related:


Redirect based on operating system


javascript,wordpress,redirect,user-agent
I'm new here and I apologize if this question is basic/stupid. I am not too familiar with coding, so please excuse my ignorance/glaring errors. I have tried to put this together using code snippets found online and luckily I don't have to code too much for this project. I am...

How can I redirect all visitors to a subdirectory but still have access to the root directory for development


regex,apache,.htaccess,mod-rewrite,redirect
I'm about to start building a site and I've set up an "Under Construction" site at http://positivechange.cl I'd like to work directly on the root directory during development so that I don't have to move all files from a development subdirectory to the root directory, so I'd like to redirect...

.htaccess allow image to display directly


php,regex,apache,.htaccess,redirect
I have many files including images, php& js scripts and subfolders. I need to redirect to index.php for any uri using .htaccess. for example: www.example.com/test should be redirect to index.php But images should not be redirected to index.php. Instead it should be printed directly in browser. For example: www.example.com/sample.jpg should...

PHP - .htaccess and GET parameters


php,regex,.htaccess,mod-rewrite,redirect
I am trying to create a simple redirect to another page on login script. Currently I am rewriting my URLS to the following format using .htaccess: RewriteRule ^login$ ?i=l [L] RewriteRule ^login([^/]*)$ ?i=l&=$1 The normal URL is therefore: domain.com/login - although I wish to be able to do the following:...

Redirect to edit page automatically if record exists


ruby-on-rails,ruby-on-rails-4,redirect
I want to create a new record if it not exist. Otherwise, redirect to edit page automatically. In case the record exists (e.g: @sale is not nil). However, I got error message: app/views/sales/_form.html.erb where line #1 raised: First argument in form cannot contain nil or be empty Please show place...

Apache htaccess redirect file


php,regex,apache,.htaccess,redirect
I want to redirect any request for file from my old website to the same file but with different url on my new website : www.oldwebsite.com/aaa/bbb/ccc/file.txt -> www.newwebsite.com/bbb/ccc/file.txt I have tried this solution on .htaccess file: RewriteEngine On RewriteRule ^(aaa/bbb/ccc/)(.*)$ http://newwebsite.com/bbb/ccc/$2 [R=301,L] but when I try with this url :...

Force WWW when URL contains path using .htaccess


.htaccess,session,url,redirect
I'm having a problem with my URL and my sessions. I wish to have ALL website pages be forced to use www. As it looks like now, the website looks like this: www.example.com into www.example.com example.com into www.example.com www.example.com/example/ into www.example.com/example/ example.com/example into example.com/example (this is what's wrong) This is...

Naked Root Domain Hosting


redirect,amazon-web-services,amazon-s3,amazon-route53
The usual approach calls for pointing mysite.com to www.mysite.com. But suppose that I would like not to redirect. In other words, I would like to set up a naked root domain, without setting up any sub-domains, not even www.mysite.com. I am using Route53 and S3. Presumably I would need just...

Redirect specific Url variables


php,.htaccess,mod-rewrite,redirect
My site used to generate URLs like this: /data.php?s=1432862823&type=basic I have modified the program so the new URLs generated are: /d.php?s=1432862823&t=basic Since some people have bookmarked the old URLs I want to write a Rewrite rule that will get them to the new url. I've not this so far: RewriteEngine...

Redirect only non-existing sub-directories to another domain using wildcard


apache,.htaccess,mod-rewrite,redirect
In Apache, how do i redirect all non-existing directories for one domain (E.g. http://example.com/*.*) to another (e.g. http://example2.com/*.*)? I don't want the redirect to occur if the directory exists on the first server (http://example.com/). Just for non-existing directories. Example: http://example.com/directoryA <--- Exists on the server, so it should NOT redirect....

How to redirect domain with www or without www


php,.htaccess,mod-rewrite,redirect
I am using the following rewrite rule to redirect domain that has or has not www. RewriteCond %{HTTP_HOST} !^www\.[NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] It works fine for any sub domain name like www.domainname.com/abc.php or domainname.com/abc.php. But not adding https in case of www.domainname.com or domainname.com. I tried...

An illustration of AWS hosted zones and buckets


redirect,amazon-web-services,amazon-s3,amazon-route53
After more than a few experiments with hosted zones and buckets, it seems I'm getting failures due to unexpired caches even though I may well have set up everything correctly. Before proceeding, I'd like to summarize using two sketches the lengthy (and frankly, tedious) AWS documentation, and ask whether these...

Tmux breaks zsh aliases


bash,shell,alias,zsh
I have a file .aliases that I point to in my .zshrc file DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" if [ -f $DIR"/.aliases" ]; then . $DIR"/.aliases" fi This code is the same in my .bashrc file (in the process of switching over to zsh). The aliases...

Redirect without changing Url htaccess


php,.htaccess,redirect
I'm wondering if this is possible - I have projects structured like: www.mydomain.com points to MyFolder on server. In MyFolder i have 3 App Folders eg MyFolder/App1, MyFolder/App2.. Each of these are 3 different web applications. Url of domain is www.mydomain.com Is it possible, that, when url user go to...

Redirecting http to https


apache,.htaccess,redirect,ssl,https
I'd like to redirect all of my http traffic to https, currently in my htaccess file I have the following redirecting my http traffic: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] </IfModule> This redirects all of my non-www to www. What is the best way to...

oh-my-zsh error after upgrade: ~/.oh-my-zsh/lib/misc.zsh:3: parse error near `then'


shell,zsh,zshrc,oh-my-zsh
today I upgrade my oh-my-zsh and then start this error: ~/.oh-my-zsh/lib/misc.zsh:3: parse error near `then' Inside this file there is this shell loop... ## Load smart urls if available for d in $fpath; do if [[ -e "$url/d-quote-magic"]]; then autoload -U url-quote-magic zle -N self-insert url-quote-magic fi done I think...

Laravel 5 pagination with trailing slash redirect to 301


php,laravel,redirect,pagination,laravel-5
I'm using Laravel 5 and notice that the pagination is adding a trailing slash before the ?page=# and with that, it always redirect to a 301 page. http://example.com/news/articles/?page=2 will do a 301 redirect to http://example.com/news/articles?page=2 This is causing my pagination using ajax to slow down because it is having 2...

Should my $PATH be returning anything RVM related?


ruby,osx,shell,zsh
I am running the command echo $PATH which is returning the following information containing RVM /Users/RAI/.rvm/gems/ruby-2.1.1/bin:/Users/RAI/.rvm/gems/[email protected]/bin:/Users/RAI/.rvm/rubies/ruby-2.1.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/RAI/.rvm/bin Should this command only return the following? /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin Note that I am currently using on My Zsh...

301 Redirect Regex Pattern - Sitecore Redirect module


regex,redirect,sitecore,url-redirection
I apologize if this seems like a rudimentary question, but I'm trying to setup a redirect pattern for the 301 module in Sitecore and am having a hard time with the proper pattern. I need to have the following path: http://www.example.com/some-path/videos/2014/08/08/15/20/some-item-title converted to: http://www.example.com/some-path/videos/some-item-title Basically strip the numerical folders out....

Why redirect PHP get only white page?


php,redirect
I'm developing in PHP, and I need to change page for different type of user, so I do in this way: switch ($_SESSION['ruolo']) { case 0: header('Location: ./php/admin/homeAdmin.php'); exit(); break; case 1: header('Location: ./php/150ore/home150.php'); exit(); break; case 2: header('Location: ./php/150ore/home150.php'); exit(); break; default: break; } But I obtain only a...

Links do not redirect to Jquery Tabs


javascript,jquery,redirect,jquery-tabs
I have 4 links as <li><a class="open-tab" href="#sirkethesaptab">Şirket Hesabı</a></li> <li><a class="open-tab" href="#musterihesaptab">Müşteri Hesabı</a></li> <li><a class="open-tab" href="#odemetab">Ödemeler</a></li> <li><a class="open-tab" href="#harcamatab">Harcamalar</a></li> <li><a class="open-tab" href="#personeltab">Personel</a></li> And i have a Jquery tab <div class="col-sm-9...

htaccess redirect to subdomain based on query string


php,apache,.htaccess,redirect,joomla
I searched for similar questions but none of them was applicable to my situation. What I need to do is redirect from old url's that have specific query string: option=com_virtuemart to a subdomain : http://parts.domain.com Tried bunch of rules and conds but haven't achieved right redirection. It was always redirecting...

PHP - Image Upload , move_uploaded_file not working?


php,redirect,image-uploading
I have coded a image upload script but when I click upload i get redirected to the upload page? Here is the code: $image1name = $_FILES['image1']['name']; $image1crntloc = $_FILES['image1']['tmp_name']; $image1ext = pathinfo($image1name, PATHINFO_EXTENSION); $image1size = $_FILES['image1']['size']; $allowedext = array("jpg","gif","png"); //check image 1 extension. if (!in_array($image1ext,$allowedext)) { echo "<script>alert(\"Image 1 has...

Make vim follow symlinks when opening files from command line


linux,osx,vim,zsh
I'm a huge vim lover, but I can't find a way to get vim to follow symlinks when opening files. As an example, all the dotfiles in my home dirs are symlinked to within the .zprezto directory: .vimrc -> ~/.zprezto/runcoms/vimrc .zshrc -> ~/.zprezto/runcoms/zshrc I'm keeping my fork of .zprezto in...

C# mvc4 - direct URL to controller


c#,asp.net-mvc-4,url,redirect
I have an external URL that points directly to a function in my controller but when I click on it for the first time, instead of reaching the page, I get to the home page. However, on the second click (and the following ones), I can reach the desired page....

PHP redirect page works only in localhost


php,mysql,forms,redirect
I haven't found any solutions for my problem so I decided to ask. I would like to redirect my php script page after submitting a form, so I use header at the end of my codes! Interestingly, when I test it in my localhost, it works and redirects the page...

Redirect /{POSTID}/{CATID}/{TITLE} to just /{POSTID}/


apache,.htaccess,redirect,rewrite
I need help with a rewrite / redirect rule to fix some duplicate content issues on my website. I have a URL structure that it causing a ton of duplicate content. The same page can be accessed with: /Static1/Static2/Static3/{POSTID}/{CATID}/{TITLE} /Static1/Static2/Static3/{POSTID}/{CATID}/ /Static1/Static2/Static3/{POSTID}/ So, there are 3 copies of every page. I...

Timeout handle email php


php,email,redirect,location,sleep
I would like to redirect my user to a new page, but the current site continues to run a script that sends a threaded message 10 minutes later at a specified address. I tried something like this: Header('Location: xy.com'); sleep(100); do_the_email_sending_here(); But actually it doesn't worked,because the site waited for...

How to redirect and then stop in node.js


javascript,node.js,redirect,express
I am trying to stop users accessing certain pages whilst logged in and not logged in with node.js. So far I have this idea: exports.blockIfLoggedIn = function (req, res) { if (req.isAuthenticated()) { //passport req.flash('error', 'Sorry but you can\'t access this page'); res.redirect('/'); } }; MA.f.auth.blockIfLoggedIn(req, res, next); res.render('users/login', {...

Redirect stdout using exec in subscript


linux,bash,redirect,command-line,sh
I have one main script which is started as an service. I can't modify this main script, because it is often updated. This main script starts a program, which echo any log to stdout. So i can't see any log of this program. But this main script calls at the...

Mod Rewrite Maintenance page that uses multiple URLs


windows,.htaccess,redirect,isapi-rewrite
I have a site the uses multiple URLs for a single application. Depending on the URL of the site you will get different content. I need to create a rewrite rule that redirects a user to a different page depending on what URL the user hits. For example: If a...

RewritePath doesn't change browser URL


asp.net-mvc,redirect
Inside my Global.asax.cs I have the following simple code: void Application_BeginRequest(object sender, EventArgs e) { if (HttpContext.Current.Request.RawUrl.Contains("/oldControler/oldAction")) { HttpContext.Current.RewritePath("/newControler/newAction"); } } The above code causes redirection to "newControler/newAction" rendering the correct View, yet the URL that shows up in the browser is still "/oldControler/oldAction". In case it's of any help,...

.htaccess - 301 redirect where the URL structures aren't identical


regex,wordpress,.htaccess,mod-rewrite,redirect
I've been looking around for the answer to this but haven't been able to solve it myself. What I'm trying to do is redirect a group of around 1500+ URLs from one format to another, where the only thing that's consistent between the two is a string of numbers at...

Javascript: OS-depending Redirects doesn't work for IOS


javascript,ios,redirect,apple
i've got a pretty simple Javascript for redirecting a specific URL to an app in Google-Play-Store/iOS-Store or show an URL for desktop users depending on the client's opersting system. For the ios case the redirect is not being executed, can anyone explain what the problem is? (alert before redirect is...

Open file in $EDITOR by default in zsh


zsh
In zsh, if you can open directories without specifying cd command, like this % pwd /home/user/test % ls integration shared unit % unit % pwd /home/user/test/unit This effectively saves writing 'cd' everytime you try to open a directory. However it's smart enough not to 'cd' into files. Would it be...

Redirect 301 with wordpress articles from a domain to another


wordpress,.htaccess,redirect
my client changed his wordpress website to a new domain. I tried with the htaccess to redirect 301 the articles dynamicaly but it's not working. The URL format of articles are : /%year%/%monthnum%/%day%/%postname%/ I put this in htaccess but not working : redirect 301 /([0-9]*)/([0-9]*)/([0-9]*)/(.*)/ http://www.newdomain.com/$1/$2/$3/$4/ Can you help me...

.htaccess | Too many redirects


apache,.htaccess,mod-rewrite,redirect
I want to add a IP filter into my .htaccess file, but after I applied it, a too many redirects error will show. Content of .htaccess: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301] RewriteCond %{HTTPS} on RewriteCond %{REMOTE_ADDR} xxx.xxx.xxx.xxx...

Get Parameter from URL using PHP


php,url,redirect
I have a url: domain.com/?city=newyork&postback=test I am currently successfully passing the postback parameter using the PHP below. However, I can not figure out how to also pass the city parameter. <?php session_start(); if(isset($_SESSION['postback'])) { if($_GET['postback'] == "") { header ("Location: qualify-step2.php?postback=".$_SESSION['postback']); } } ?> Can someone please help me edit...

mod_rewrite - force redirecting to rewritten URL


apache,.htaccess,mod-rewrite,redirect
I have following URL [1]: www.domain.com/?search=somequery which i want to redirect to [2] www.domain.com/search/somequery I am using following code in my .htaccess: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^search/(.*)$ /?search=$1 [L] Code above works kind of fine since server understands both URLs:...

Grails: Carry forward params on hyperlink is clicked


grails,redirect,controller
How to carry forward the parameters when hyperlink is clicked? Here is my gsp code: <g:link class="grid_link" controller="user" action="delete" id="${userInstance.id}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure, want to delete?')}');">Delete</g:link> Here is my controller code: def delete() { try { def userInstance = User.get(params.id) //deleting the user //successful. redirect(action: "list",...

How do I redirect a URL with a parameter to a clean URL in htaccess?


.htaccess,mod-rewrite,redirect
I am attempting to 301 redirect several URLs with parameters at the end to clean URLs. For example I am trying to redirect: http://example.com/news/news.php?id=1234 to http://example.com/posts/vanity-url.php Here is my code: RewriteCond %{QUERY_STRING} id=1234 RewriteRule ^news/news\.php$ /posts/vanity-url.php [L,R=301] I feel like I'm close with this code but it redirects me to:...

Redirect to a homepage cakephp 3


php,redirect,routes,cakephp-3.0
I've followed the articles tutorial from cakephp 3 website and created the website http://i.imgur.com/JMh1Pwv.png Now there is add article, delete article and edit article actions. When I delete an article it redirect me to http://localhost:8888/test/articles/delete/14 Here is the delete code. public function delete($id) { $this->request->allowMethod(['post', 'delete']); $article = $this->Articles->get($id); if...

Cannot get wp_redirect to work


wordpress,redirect
I'm trying to send an email using wp_mail and then, if mail is sent successfully, redirect user to another page (or, if not successful, to an error page). My code is shown below. The email is actually sent, so wp_mail is working, but I cannot get the redirect to work....

Use JS to convert URL #fragment BEFORE it gets lost to 301 redirect?


javascript,redirect
In real trouble here. Our old website featured a gallery slider that used URL #fragments to position a jQuery slider on the right project. For instance, /work/interactive#777 brought you to the /work/interactive page--which shows one project at a time in a slider--and then animates the slider to project with the...

python requests with redirection


python,authentication,redirect,curl,python-requests
Trying to authenticate on http://72.ru site, noticed that there were a redirect to https://loginka.ru/auth/. Found that there were 302 POST with plain credentials in data form. Copying headers from Chrome can reproduce that in cURL, but still can't reach in requests module. Warning: page is full of russian letters, registration...

How to redirect user to another internal page?


javascript,redirect,parse.com
After creating the record, the user would be redirected to an internal page. "redirect to home.html" I've tried, add the code under "Sucess" but had no success :( How to be redirected after register or log in? window.location.href = "http://stackoverflow.com"; With the above code only works after pressing F5 <script...

Why mozilla changes the characters when i use the .net mvc statement redirect?


c#,asp.net-mvc-4,redirect,mozilla
I'm trying to redirect to an external website when everything is done, but firefox changes the http word on the url for a weird set of characters. This is my server side code: [HttpPost] public ActionResult Postular(INFO_BASE_POSTULACION_model pInfoPostulacion) { string rutMD5 = Request["rutMD5"]; int idRegion = Convert.ToInt32(Request["idRegion"]); int idInstrumento =...

Htaccess regex: exclude REQUEST_URI


regex,apache,.htaccess,mod-rewrite,redirect
I really tried everything, the tool htaccess tester says that it's ok, but it's not really working. I want to redirect a subdomain to the main domain only if the REQUEST_URI doesn't start with 3 specific strings. I tried without success with: RewriteCond %{HTTP_HOST} ^sub.example.com$ [NC] RewriteCond %{REQUEST_URI} !(aaa|bbb|ccc) RewriteCond...

Excluding certain pages from being redirected to https


wordpress,.htaccess,redirect,https,http-redirect
I'm using the following rules on my WordPress website to: Redirect all http pages to https Redirect the careers page to http <IfModule mod_rewrite.c> RewriteEngine On # Go to https if not on careers RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} !^/careers$ [NC] RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R,L] # Go to http if...

redirect after 5 seconds but only allow the page to be accessed by the refferer [SOLVED]


javascript,php,.htaccess,redirect
After 16 hours of constant trying and learning as i go along.. im no better off and become over frustrated! So im now in desperate need of help, Any advice or help would be greatly appreciated. I am trying to have page1.php redirect to page2.php after 5 seconds, However page2.php...