I know about RSA authentication, but for my purposes I want to use a heredoc to specify the password. I want something like the following, but I can't get it to work. Is this even possible?
#!/bin/bash
echo -n "Enter Password: "
read -s password
ssh myhost << EOL
$password
echo "I'm logged onto myhost"
EOL
echo done
This is what I g...
This is the code
for f in tmp_20100923*.xml
do
str1=`more "$f"|grep count=`
i=`echo $str1 | awk -F "." '{print($2)}'`
j=`echo $i | awk -F " " '{print($2)}'` // output is `count="0"`
sed 's/count=//g' $j > $k; echo $k;
done
I tried to get value 0 from above output using sed filter but no success. Could you please advi...
Is " - " a shortcut for stdout in bash? If not what does it mean? For example,
wget -q -O - $line
How about stdin?
Thanks and regards!
...
why does:
#!/bin/bash
wtf=false
if [ $wtf ] || [ ! -f filethatexists.whatever ]
then
echo "WTF1"
fi
if [ ! -f filethatexists.whatever ]
then
echo "WTF2"
fi
print:
WTF1
instead of nothing? It is especially perplexing that the second form works as expected and the first not.
...
Say I have too programs a and b that I can run with ./a and ./b.
Is it possible to diff their outputs without first writing to temporary files?
...
Hello, I am trying to make a shell script to remove special characters, like {}()!,' etc. So far I have referenced a past question I asked here, however I get a strange error message:
-bash-3.2$ ./test2.sh
./test2.sh: line 7: unexpected EOF while looking for matching `"'
./test2.sh: line 10: syntax error: unexpected end of file
test2....
How can you display how a bash script would look like with the variables expanded?
I want see how what the script would actually execute, without doing any damage.
...
I am trying to run a.out lot of times from command line, but am not able to start the processes in background because bash treats it as a syntax error.
for f in `seq 20`; do ./a.out&; done //incorrect syntax for bash near '&'
How can I place & on command line so that bash doesn't complain, and I am allowed to
run these processes in b...
i had made a small bash script in order to get the frequency of items in a certain column of a file.
The output would be sth like this
A 30
B 25
C 20
D 15
E 10
the command i used inside the script is like this
cut -f $1 $2| sort | uniq -c |
sort -r -k1,1 -n | awk '{printf "%-20s %-15d\n", $2,$1}'
how can i mod...
Is it possible to have a bash script automatically complete prompts that would normally be presented to the user with default actions? Currently I am using a bash script to call an in-house tool that will display prompts to the user (prompting for Y/N) to complete actions, however the script I'm writing needs to be completely "hands-off...
According to section 3.7.1 of the Bash manual, variable assignments at the beginning of a command line should be visible to the invoked program.
e.g.
DIR=/tmp ls $DIR
should behave as if I've typed "ls /tmp" - and the variable DIR should not persist after executing the command.
Cygwin Bash (GNU bash, version 3.2.51(24)-release (i686...
How can I iterate over multi-line regexp matches using sed and bash?
I'm trying to generate some quick docs from comments in a file, like so:
/**
* @name myFun
* @return {int}
*/
I can extract every comment block using sed -n -e '/\/\*\*$/,/\*\/$/p', but now I'd like to stuff each match into a bash array so I can parse the details ...
I have two text files, each of them contains an information by line such like that
file1.txt file2.txt
---------- ---------
linef11 linef21
linef12 linef22
linef13 linef23
. .
. .
. .
I would like to concatenate thes...
I have 2 machines A and B.
I wish to have the output from B printed in a terminal on A.
I run the following in a loop on A:
nc -l -p 65000
On B, all output is tee'd to /dev/tcp/A/65000
This works most of the time, but output from programs such as 'ls' lose their colour and tab formatting. Is there any way to get this to work, such ...
I am trying to compare the $duration variable to an int, to see how long it is. I need to deturmine how many 0's to append to the file name to maintain clean names e.g.
cap_000001.png
cap_002938.png
My current statement is:
if [ $duration < 1000 ]; then
sudo ./v2u cap_000$duration.png
echo 1000 seconds
fi
if [ $duration < 10...
I'm trying to determine if a file or directory doesn't exist. I tried the following commands to see if a file does exist and they work correctly:
if [ -a 'settings.py' ]; then echo 'exists'; fi
exists #output
if [ -a 'foo' ]; then echo 'exists'; fi #outputs nothing
But when I try this:
if [ ! -a 'settings.py' ]; then echo 'does not e...
I'm using pdftotext to convert Spanish language text. Characters with accents or tildes are output in a systematic way that requires further conversion. Accents and tildes appear in the converted text in the correct position but without the letter. The letter almost always appears at the end of the output line. When it doesn't, I can...
i have following pattern
parts=/a,1mb,/b/c,2gb,/zee/last,-1 #general form on next line
^parts=path1,size1,...,lastPath,-1$
I want to replace all $path1,$size1 except $lastplace,-1 with $newPath,$newSize i.e.
parts_new=/p,2mb,/q/r,5gb,/zee/last,-1 #general on next line
^parts=newPathX,newSizeX,lastPath,-1$
I figured how to do it usi...
I have a problem with rlwrap (see the man page here). Consider this situation: empty.tcl is an empty file. At bash this line
tclsh empty.tcl &
runs the job in the background and exits it, so i get this prompt
[1]+ Done tclsh empty.tcl.
While this line
rlwrap tclsh empty.tcl &
runs the job in the background and ...
I have defined the following variable:
myVar=true
now I'd like to run something along the lines of this:
if [ myVar ]
then
echo "true"
else
echo "false"
fi
The above ode does work, but if I try to set
myVar=false
it will still output true.
What might be the problem?
edit: I know I can do something of the form
if [ "$m...