Questions tagged [echo]

Simple function outputting text. Exists in script languages.

echo is mainly used in batch (cmd). An example would be:

echo hello world

which prints "hello world" to the terminal.

The output by default prints directly to the command line, however, it may be piped into a following command as an input. This can be very handy and allows for interoperability between different processes/languages.

5742 questions
118
votes
9 answers

Why can't I specify an environment variable and echo it in the same command line?

Consider this snippet: $ SOMEVAR=AAA $ echo zzz $SOMEVAR zzz zzz AAA zzz Here I've set $SOMEVAR to AAA on the first line - and when I echo it on the second line, I get the AAA contents as expected. But then, if I try to specify the variable on…
sdaau
  • 36,975
  • 46
  • 198
  • 278
101
votes
6 answers

Why sudo cat gives a Permission denied but sudo vim works fine?

I am trying to automate the addition of a repository source in my arch's pacman.conf file but using the echo command in my shell script. However, it fails like this:- sudo echo "[archlinuxfr]" >> /etc/pacman.conf sudo echo "Server =…
Calvin Cheng
  • 35,640
  • 39
  • 116
  • 167
93
votes
7 answers

How do I print all POST results when a form is submitted?

I need to see all of the POST results that are submitted to the server for testing. What would be an example of how I can create a new file to submit to that will echo out all of the fields which were submitted with that form? It's dynamic, so some…
Zoolander
  • 2,293
  • 5
  • 27
  • 37
89
votes
8 answers

using batch echo with special characters

This maybe really easy but there were no answers for it over the net. I want to echo a XML line via batch into a file but it misunderstands the XML closing tag for redirection ">". The line is as follows: echo
Amir Zadeh
  • 3,481
  • 2
  • 26
  • 47
84
votes
5 answers

Echo off but messages are displayed

I turned off echo in bat file. @echo off then I do something like this ... echo %INSTALL_PATH% if exist %INSTALL_PATH%( echo 222 ... ) and I get: The system cannot find the path specified. message between those two echos. What can be the reason…
Aleksandr Kravets
  • 5,750
  • 7
  • 53
  • 72
82
votes
4 answers

PowerShell "echo on"

This is a duplicate of https://serverfault.com/questions/102098/powershell-script-showing-commands-run. I thought it would be more appropriate to ask this question here. I am playing around with PowerShell scripts and they're working great.…
Nelson Rothermel
  • 9,436
  • 8
  • 62
  • 81
80
votes
8 answers

OpenVPN on Linux: passing username and password in command line

I am using IPVanish for using a proxy while surfing; like: sudo openvpn --config /home/ipv/conf/ipvanish-CA-Toronto-tor-a09.ovpn Now, I have to enter my username, after that my password. How Can I pass those two params right as one command, so that…
JOhnlw009a
  • 1,012
  • 1
  • 7
  • 12
80
votes
3 answers

Echo off in Jenkins Console Output

I'm following guideline how to sign Android apk with Jenkins. I have parametrized Jenkins job with KSTOREPWD and KEYPWD. A part of Jenkins' job configuration (Build->Execute shell) is to take those parameters and store them as environment…
Marian Paździoch
  • 8,813
  • 10
  • 58
  • 103
77
votes
6 answers

PHP echo vs PHP short echo tags

Are they equal in safeness? I was informed that using was less safe, and that it slows down page load times. I am strictly biased to using echo. What are the advantages/disadvantages?
homework
  • 4,987
  • 11
  • 40
  • 50
74
votes
11 answers

How to echo "2" (no quotes) to a file, from a batch script?

How do I echo the number 2 into a file, from a batch script? This doesn't work: Echo 2>> file.txt because 2>> is a special command. :(
user541686
  • 205,094
  • 128
  • 528
  • 886
74
votes
18 answers

How to flush output after each `echo` call?

I have a php script that only produces logs to the client. When I echo something, I want it to be transferred to client on-the-fly. (Because while the script is processing, the page is blank) I had already played around with ob_start() and…
cusspvz
  • 5,143
  • 7
  • 30
  • 45
72
votes
5 answers

How do I make a Windows batch script completely silent?

There has been variants of this question asked for generations, but despite writing some quite complicated Windows scripts, I can't seem to find out how to make them actually silent. The following is an excerpt from one of my current scripts: @ECHO…
Mike Sadler
  • 1,750
  • 1
  • 20
  • 37
72
votes
9 answers

Is there a php echo/print equivalent in javascript

Say I want to print html from inside a script tag. A source like this
foo
bar
should look something like this in browser after the script has…
jpeltoniemi
  • 5,320
  • 7
  • 24
  • 34
70
votes
3 answers

How can I echo the whole content of a .html file in PHP?

Is there a way I can echo the whole content of a .html file in PHP? For example, I have some sample.html file, and I want to echo that filename, so its content should be displayed.
Nikola Nastevski
  • 917
  • 5
  • 14
  • 25
68
votes
6 answers

How to get osx shell script to show colors in echo

I'm trying to add color output to my errors in a bash script that I have running on a mac. The problem is the colors are not working. I created the simplest of scripts to demonstrate that it does not work: #!/bin/bash echo -e "\e[1;31m This is…
nycynik
  • 7,371
  • 8
  • 62
  • 87