Issue#2271: Linux - [SOLVED] Bash script : event not found when I echo my password into ssh

  • Hi all

    I am automating some ssh connections on my laptop. I use this bash script:

    echo my!pass | ssh hostname

    I get this:

    -bash: !pass: event not found

    Well, my password contains ! and I really don't like to change it.

    What does this mean and how can I fix it?

    Please note: I can't use expect

    Error seen on SunOS and MAC El Capitan

    Thanks!

    0 Answers

    Sorry, your answer is too short !

  • Issue#44073: Linux - [SOLVED] bash script: can echo command, command works if I type, but command doesn't work in

    My goal is to understand what is going on: The following script is given the name 'marg': ------------------------------------------------ #!/bin/bash d=$(dirname "$1") b=$(basename "$1") echo find "$d" -name ""$b"" -type f -print ------------------------------------------------ If I type marg './foo/*' bar/ in an xterm, the result is find ./foo -name "*" -type f -print If I type the above command into an xterm it executes ok. But if I change marg to ------------------------------------------------ #!/bin/bash d=$(dirname "$1") b=$(basename "$1") find "$d" -name ""$b"" -type f -print ------------------------------------------------ then If I type marg './foo/*' bar/ in an xterm, the result is that the find command does not execute. WHY? P.S. For those wondering "what am I trying to do?" the answer is: I am trying to understand what is going on with the

  • Issue#2727: Linux - [SOLVED] bash: ping: command not found

    Hello. why "ping" command not exist on Debian Jessie x64 by default? $ /bin/p pidof ps pwd $ /usr/sbin/p pam-auth-update pppdump pwck pam_getenv pppoe-discovery pwconv pam_timestamp_check pppstats pwunconv paperconfig psad pppd psadwatchd I installed "inetutils-tools" and "inetutils-ping" for solve this problem.

  • Issue#317629: Linux - [SOLVED] How to import a file into bash script?

    These are my files: $ ls -al my_fake_service.* -rwxr--r-- 1 user1 user1 396 Mar 20 16:33 my_fake_service.sh -rw-rw-r-- 1 user1 user1 25 Mar 20 16:17 my_fake_service.txt ~/test/linuxlab $ cat my_fake_service.txt VAR1="true" VAR2="false" ~/test/linuxlab $ cat my_fake_service.sh #!/sbin/bash # Is this how to include a file into Bash script? ./home/user1/test/linuxlab/my_fake_service.txt if [[ ${VAR1} == "true" ]] then echo "VAR1 set to true" >> ~/test/linuxlab/my_fake_service.log else echo "VAR1 set to false" >> ~/test/linuxlab/my_fake_service.log fi if [[ ${VAR2} == "true" ]] then echo "VAR2 set to true" >> ~/test/linuxlab/my_fake_service.log else echo "VAR2 set to false" >> ~/test/linuxlab/my_fake_service.log fi --------------------------- When I ran the script, I got this error. What is causing it? ~/test/linuxlab $ bash my_fake_service.sh my_fake_service.sh: line 2: ./home

  • Issue#701898: Linux - [SOLVED] Bash Script too Many Arguments error

    With the following code I'm attempting to accept a name as input from the script user. However, when I enter a first and last name, I get an error that there are "too many arguments". Any obvious reason I'm not able to accept 2 word answers? Thank you! if [ "$nomore" -eq 0 ];then # { mgrName= while [ -z "$mgrName" ];do # { read -p "Manager Name (enter q to quit) ? " mgrName if [ -z "$mgrName" ];then perror You must provide a manager name. elif [ $mgrName == q ];then nomore=1 fi done # } fi # }

  • Issue#791382: Linux - Bash Script Issue

    Hello - I've run into an odd little scripting problem where if I run the script from the command line it works fine and adds two at jobs. But when run from the crontab it only creates the sunrise job. I had both working (see original sunset line) until I wanted to make the sunset job run 15 minutes before sunset. I'm using this to turn house lights on/off and am using Dan Risacher's sunwait program (http://www.risacher.org/sunwait/). Any suggestions would be appreciated. Bill Richards -------------------- script ---------------------- #!/bin/bash # original line to calculate sunset #sunset=`/usr/local/bin/sunwait -p 35.41N 97.35W |/bin/grep "Sun rises"|/usr/bin/cut -d" " -f25` # line to calculate 15 minutes before sunset sunset=$((`sunwait -p 35.41N 97.35W |grep "Sun rises"|cut -d" " -f25` - 15)) # line to calculate sunrise sunrise=`/usr/local/bin/sunwait -p 35.41N 97.35W |/bin/grep "Sun rises"|/usr/bin/cut -d" " -f22` #

  • Issue#1188564: Linux - Bash script, appropriate variable to store password

    Hello, I have a script that connect to remote devices using ssh, the script knows my username, but always asks my password. I want the script to ask it once, put it in a variable only accessible by my user and I want the variable to remain so that it would be recognized every time I call the script. If my session ends, I want the variable to be reset. Is there such variable? If so, how do I call it in my script?

  • Issue#3185: Linux - [SOLVED] libav headers not found

    I have two computers running Slackware64-current. On one of them I can't install dvdstyler because libav headers are not found. On the other I get no such error and dvdstyler installs just fine. Why would this happen? Edit: Immediately realize ffmpeg is not installed.

  • Issue#58947: Ubuntu - [SOLVED] Bash script: obtain running user while executing with sudo previleges

    Hi, I need to execute a script as sudo user and for this reason I wrote this code Code: #!/bin/bash user=$USER if [[ $EUID -ne 0 ]]; then   echo "This script must be run as root, use sudo "$0" instead" 1>&2   exit 1 fi I had a problem with the value of the variable $USER that is root instead of the current running user as if I had executed without sudo. How can I obtain the current running user instead of root? Have I to pass the correct values during the calling of script? Thank you

  • Issue#67314: Linux - bash: wine: command not found

    hello group, im new to linux. im having a problem wine. i had installed wine [[email protected] Desktop]# find / -name "wine" /usr/local/include/wine /usr/local/share/wine /usr/local/lib64/wine /usr/src/wine-1.8/wine /usr/src/wine-1.8/include/wine /usr/src/wine-1.8/libs/wine but when i type wine --version [[email protected] Desktop]# wine --version bash: wine: command not found when i echo to see the path [[email protected] wine-1.8]# echo $PATH /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin [[email protected] wine-1.8]# cat /etc/profile # /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates. pathmunge () { case

  • Issue#81452: Linux - SSH Script - Connection Not Visible

    Wrote SSH script. It seems to be running, connecting to servers in my server list file via SSH. Problem is, I cannot see the session or prompt to see password input... Something about running ssh in script needs to be >/dev/null 2>%1 ??? Please help :) Code: #!/bin/bash SERVERS=servers for SERVERS in 'cat servers' do ssh MyUserName@$SERVERS df -h done

  • Issue#87206: Linux - [SOLVED] Pulseaudio and wine (sound issue) on -current

    I am using mostly playonlinux (so all different versions of wine) however i get this problem with both the wine package from slackbuilds, and within playonlinux, when configuring wine (winecfg) and testing the sound. I can hear no sound in any games, or with the test button; this prints out in the terminal: Code: Aerr:module:load_builtin_dll failed to load .so lib for builtin L"winepulse.drv": libjson-c.so.2: cannot open shared object file: No such file or directory ALSA lib dlmisc.c:254:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/alsa-lib/libasound_module_pcm_pulse.so ALSA lib dlmisc.c:254:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/alsa-lib/libasound_module_pcm_pulse.so err:ole:CoInitializeEx Attempt to change threading model of this apartment from multi-threaded to apartment threaded I had recently installed these packages alsa-plugins-compat32-1.1.0-x86_64-2compat32 pulseaudio-compat32-8.0-x86_64-1compat32 , hoping they provide what migh

  • Issue#92241: Linux - bash script using aria2 not working

    I found a bash script with wget here : Code: http://www.linuxquestions.org/questions/showthread.php?p=5470985 I want to use aria2. its giving bad variable name. the script is: Code: echo "Name" read name echo start no. read incr while read i   do     aria2c "$i" -x 16 -o $name_ep$incr     incr=$((incr+1)) done < $name Can anyone help me?

  • Issue#135788: Linux - bash script - editing some files to add more lines

    hi all, i have created a basic kickstart file and its great it all works (complete unattended install) but i want edit /etc/group to add new groups and add a user to that group eg group_name:x:500:root and also make a directory eg mkdir /mnt/new_dir and also put a new entry in fstab to mount it to that local directory eg ip_address:/remote_share_path /mnt/new_dir nfs defaults 0 0 cheers rob

  • Issue#139303: Linux - bash function to check if script dependencies are installed...

    hi, all of my bash scripts start with something like this: Code: dependencies=('jq' 'wget') checkScriptDependencies "${dependencies[@]}" here is the code for checkScriptDependencies: Code: checkScriptDependencies () { # "${dependencies[@]}"         local _packages=( "$@" )         local _package=         for _package in ${_packages[@]}; do                 hash $_package                 if (( $? > 0 )); then                         sudo apt-get install $_package                 fi         done } it works pretty good, but it will fail if the command name doesn't match the package name. hxnormalize and hxselect, for example, are installed with html-xml-utils package. if html-xml-utils is not in

  • Issue#148358: Linux - [SOLVED] FILENAME.sh: line NUMBER: VARIABLE: not found

    This is driving me insane. I think it has to do with Synology This is being ran on a Synology Server. Code: ### VARIABLES ### LOGIF=/volume7/homes/admin/scripts/data/achclean-logi.txt HOWOLD=$(cat $LOGIF | wc -l) # END DEFINITIONS if (( ${HOWOLD} >= 7 )); then   echo -e "WORKS" >> fi I get this error in the terminal: scriptname: line Number: [Value of HOWOLD]: not found If I run this on Linux, RedHat, it works. Code: HOWOLD=$(cat dfile | wc -l) if (( ${HOWOLD} >= 2 )); then   echo "WORKS" fi EDIT: NO LUCK!!!!!!!! Code: if [ "$HOWOLD" >= "7" ]; then # if 7, then it's been 7 days! sh: 7: unknown operand NO LUCK!!!!!!!! Code: if (( "$HOWOLD" >= "7" )); then # if 7, then it's been 7 days! scriptname: line Number: [Value of HOWOLD]: not found

  • Issue#156007: Linux - Bash Script Help Request

    I am new at writing bash scripts. Would anyone please assist me in writing one? I would like to compare two files and determine if lines are not present in one of them but are in the other. The lines are not sequential and I would like to ignore the first word in each line. Example: FileA: Code: created test1 created test2 created test3 created test4 FileB: Code: same test1 same test2 created test5 If I execute command: Code: grep -Fvf FileB FileA Since the first word in the lines are different, the output from the command is: Code: created test1 created test2 created test3 created test4 The results I would like would be: Code: created test3 created test4 Any way to ignore the first word in each line in the file being compared to, in this example FileA? Thanks!

  • Issue#160313: Ubuntu - BASH Script command not found

    Hello everyone, I am trying to write a BASH script and when I execute it I get "command not found". When I run the following from the terminal window it works like a charm filebot -script fn:amc "/home/pi/usrmnt/Target/TV" --def "seriesFormat=\\\\TITANSERVER/Series.Pool/{n}/{episode.special ? 'Special' : 'Season '+s.pad(2)}/{n}.{s00e00}{'.'+fn.match(/(?i:proper)/).toLowerCase().upperInitial()}{'.'+fn.match(/(?i:repack)/).toLowerCase().upperInitial()}{'.'+[vf]}{'.'+[vc]}{'.'+[ac]}{'.'+[af]}{'.'+[source]}{'.'+[group]}.{t}" -r --log-file "/home/pi/log/Filebot.log" --action move --conflict override -non-strict --def backdrops=y --def artwork=y --def clean=y --def ut_label=tv --def excludeList="/home/pi/log/amc-input.txt" > /home/pi/log/filebot.TV.log 2>&1 I can read the log and all is well but when I create a BASH script Code: #!/bin/bash filebot -script fn:amc "/home/pi/usrmnt/Target/TV" --def "seriesFormat

  • Issue#165228: Linux - How to choose correct /dev/sdX for a bash script

    Hi there, I have written a little script that formats a usb stick on a raspberry pi, however, it only works when I can guarentee that the usb is mounted to "dev/sda", however it is not ideal. How can I get this script to check where the USB drive is mounted? Here is the script: Code: #!/bin/bash NAME="USB_Format"; echo -en "\033]0;$NAME\a" clear sleep 0.75s wmctrl -a "USB_Format" # clears screen and keeps focus on window echo "Enter event name >" read -r event event=${event^^} event=${event// /_} sudo umount /dev/sda1 # If the usb stick is mounted during fdisk, it needs rebooting # before any other commands can run, so unmounting the usb helps # the script run better. (echo d; echo o; echo n; echo p; echo 1; echo ; echo ; echo t; echo b; echo w) |sudo fdisk /dev/sda # this command passes the required user input: # d - deletes partition. # o - creates a new DOS partition table. # n - creates a new partition formatted to

  • Issue#167706: Linux - Issue with transmission script sending email

    I have transmission set to call a script when a torrent is completed. The script copies and transfers some files etc. and then sends an email when script is complete. Everything functions properly except the email isn't sent. If I run the script from command line as myself it works fine. Any help as to why it wouldn't works when called by transmission is appreciated.

  • Issue#170922: Linux - Need help in bash script to identify files from last month

    Hi Guys, I have a server which stores the files by this name and sa on 2016-02-12_205254_1.log 2016-02-13_090923_1.log 2016-02-14_225904_1.log 2016-02-15_171616_2.log I need to run the script on 1st day or every month so that last month's log files can be zipped/tarred and scped to my backup server. How do I find a way to get the files from last month, zipping/sciping should not be an issue. Any clue would be really appreciated.

  • Issue#174371: Linux - Get bc script variable into a bash script variable?

    I have bash script I'm writing with a bc script in it. Code: #!/bin/bash clear taxa=0.0 echo "Enter earnings "; read e ot=$(<tess) export e; export ot; export taxa bc -q << EOF scale=20 e=$e ot=$ot nt=ot+e print nt, "\n" if (nt<25000) tax=e*.05 if (ot>25000 && nt<50000) tax=e*.10 if (nt>=25000 && nt<=50000 && ot<25000) {a=25000-ot; b=nt-25000; c=a*.05; d=b*.10;tax=c+d} if (ot>50000 && nt<75000) tax=e*.15 if (nt>=50000 && nt<=75000 && ot<50000) {a=50000-ot; b=nt-50000; c=a*.10; d=b*.15;tax=c+d} if (ot>75000 && nt<100000) tax=e*.20 if (nt>=75000 && nt<=100000 && ot<75000) {a=75000-ot; b=nt-75000; c=a*.15; d=b*.20;tax=c+d} if (nt>=100000) tax=e*.25 print tax, "\n" taxa=tax quit EOF echo "scale=2; $taxa" | bc I'm trying to get the bc variable taxa into a bash variable,$taxa, within the bash script. Thank you for a

  • Issue#177375: Linux - Cert based SSH access and scripts still prompting for a password

    Hi I've set up cert based SSH access between two Ubuntu 14 LTS boxes. This works fine. On BoxB I have a script that wants to Rscript files from BoxA to BoxB using a user called rsyncuser. This use can access BoxA from BoxB using cert based SSH without being prompted for a password (this I can test). However when I run my script it immediately asks me for the password to ssh in to BoxA. Clearly this isn't great as the script stops. To cover myself, I've also enabled cert based SSH for every user involved, the user running the script, the user mentioned in the rsync command line, and also both as sudo. Any ideas what I've missed? The rsync command is below, along with the commands I've used to enable cert-based ssh (which I've used before *** rsync -arv -e "ssh" --exclude-from=/var/www/rsync_excludes.txt [email protected]:/ / *** cert-less ssh created using *** ssh-keygen ssh-copy-id -i box.b.my.domain ***

  • Issue#193759: Linux - bash script to convert a file

    I have a file (totalenergy.dat) containing the lattice constants and total energies per atom and i want to convert it to to a file (cohesive.dat) containing atomic volumes and cohesive energies by the script. How do i write the script? where the cohesive energy = (total energy per unit cell/number of atoms)-energy per atom

  • Issue#206881: Linux - Bash script to output site status out of Google Safe Browsing page?

    Hello, i would like bash script to extract the site status message at https://www.google.com/transparencyr...#url=yahoo.com You see: Quote: Current status: Not dangerous Safe Browsing has not recently seen malicious content on yahoo.com. The "Not dangerous , Safe Browsing has not recently seen malicious content on yahoo.com." appears to be dynamically generated (or how to name that, is it jquery?), because when i use: curl URL_ADDRESS lynx --dump URL_ADDRESS it outputs whole page texts which contains all possible statuses. Which Linux command to use to get real status of the webpage (example: "Not dangerous")? Thank you

  • Issue#227597: Linux - How to replace in an bash script variable?

    Hello, im having urlfile and each url in it contains $ip variable which i need to replace by actual IP that is actual for the present "while loop" cycle: Code: while read ip;do while read url;do curl -s "$url" >> output done < urlfile done < ipfile # cat urlfile http://domain1.com/?something&?ipp=$ip http://domain2.com/?ipaddr=$ip&something=something http://domain2.com/?a=lldd?ipaddr=$ip#something But i dont know what is the clever/low resource usage/low amount of code way to replace that $ip variable inside the URLs that i have either in urlfile or in variable that i populate somehow out of urlfile? Thanks in advance

  • Issue#237296: Linux - Using public/private keys to SSH instead of a password

    I wish to SSH into my server without using a password. I am using https://wiki.centos.org/HowTos/Network/SecuringSSH as a guide. I left passphrase empty. I thought I was doing everything correct, but as seen, I still require a password. What am I doing wrong? Code: [[email protected] ~]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/LocalUsername/.ssh/id_rsa): /home/LocalUsername/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/LocalUsername/.ssh/id_rsa. Your public key has been saved in /home/LocalUsername/.ssh/id_rsa.pub. The key fingerprint is: xxxxx [email protected] The key's randomart image is: +--[ RSA 2048]----+ xxxxx +-----------------+ [[email protected] ~]$ chmod 700 ~/.ssh [[email protected] ~]$ chmod 600 ~/.ssh/id_rsa [[email protected] ~]$ scp ~/.ssh/id

  • Issue#251560: Linux - sudoers.d - trying to run a script without a password for xfce4-genmon-plugin

    I wanted to read the battery power draw in watts I have read numerous webpages and settled on adding the script to sudoers. So I created a file, "panel", in /etc/sudoers.d which reads Cmnd_Alias PANEL = /usr/local/bin/panel.sh ALL ALL = (ALL) NOPASSWD:PANEL Defaults!PANEL !requiretty I have tried a few variations of the above, this is the current one. The script has a few lines like AMPS=$(cat /sys/class/power_supply/BAT0/current_now) Before I had sudo cat, and it worked, but only if I entered my password. Obviously I need to get rid of the password requirement for genmon. So I just removed the sudo command from the script but now it just returns 0. I've obviously stepped into a hole somewhere but I can't find the answer. Anyone got any ideas???? Never mind I'm an idiot. It works I just had the power plugged in. How do I delete this?

  • Issue#264306: Ubnt - Airfiber ssh algorythm issue w/ modern linux (ubuntu 16.04, rhel7)

    The AF5X firmware 3.2 seems to be missing secure ssh algorythms. ssh: connection to AF5X exited: no matching algo enc c->sssh: connection to AF5X exited: no matching algo kex Which causes CRM Control to not be able to log in. I dont know what algorythms are compiled into dropbear on the AF5X, so I can't add them to the Linux box hosting CRM Control. Ideas?

  • Issue#290189: Linux - LXer: Bash Shell Script: Building Your March Madness Bracket

    Published at LXer: I must admit that I don't really follow basketball. But, I do like to engagewith folks at work, and every spring I've always felt a little left outwhen my work colleagues fill out their NCAA March Madness basketballbrackets. If your office is like mine, it seems everyone getsvery excited to build their brackets and follow the basketball games andplay in an office pool. Read More...