Search Results

Search found 5884 results on 236 pages for 'bash scripting'.

Page 1/236 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to reset Bash on Mac OSX, .bash_profile corrupted and bash no longer works

    - by user1463172
    I am on a MacBook Pro, running the latest version of Mountain Lion. I really need some help, I have managed some how to damage my .bash_profile (I think) so that every time I open up the terminal I get the error listed below. -bash: export: `/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/go/bin': not a valid identifier -bash: export: `/Users/rob/Applications/sbt/bin:': not a valid identifier env: bash: No such file or directory env: bash: No such file or directory env: bash: No such file or directory env: bash: No such file or directory env: bash: No such file or directory -bash: tar: command not found -bash: grep: command not found -bash: cat: command not found -bash: find: command not found I am not sure what has happened, I have no sudo, cd or any normal commands. The only way I have been able to get to any of the main directories is through the go to folder command in finder and try to find the file to no avail. To top it all off I think I created a file that might be causing the issue, I wanted to edit the .bash_profile so I typed sudo nano ./bash_profile This open a new file in nano which I think was then saved. After this I opened the real .bash_profile to add in the path for node.js. If I can get to the .bash_profile I think I can get it back on track but I can't find it, should I reinstall bash? If so how would I do that on a mac, I tried using brew install bash to which I get -bash: brew: command not found I am really stuck if anyone can help I would be really appreciated. Many thanks

    Read the article

  • First 10 programs in a new scripting languge

    - by pro_metedor
    When a peron is learning a new scripting language like: bash python perl pike What kind of simple (yet practical) problem solutions to get through to make say that a person is comprehend with this scripting language enough to approach some complex yet still practical problems encountered in everyday job. In other words, which problems would you give that person to solve to make sure that he/she is familiar with the scripting language.

    Read the article

  • why is $0 set to -bash?

    - by James Shimer
    First login process name seems to be set to "-bash", but if I subshell then it becomes "bash". for example: root@nowere:~# echo $0 -bash root@nowere:~# bash root@nowere:~# echo $0 bash -bash is causing some scripts to fail, such as . /usr/share/debconf/confmodule exec /usr/share/debconf/frontend -bash Can't exec "-bash": No such file or directory at /usr/share/perl/5.14/IPC/Open3.pm line 186. open2: exec of -bash failed at /usr/share/perl5/Debconf/ConfModule.pm line 59 Anyone know the reason $0 is set to -bash?

    Read the article

  • BASH Scripting: Check If running with sudo/superuser, if not, dont run, return error

    - by EvilPhoenix
    This is something I've been curious about. I make a lot of small bash scripts (.sh files) to do tasks that I routinely do. Some of those tasks require everything to be ran as superuser. I've been curious: Is it possible to, within the BASH script prior to everything being run, check if the script is being run as superuser, and if not, print a message saying You must be superuser to use this script, then subsequently terminate the script itself. The other side of that is I'd like to have the script run when the user is superuser, and not generate the error. Any ideas on coding (if statements, etc.) on how to execute the aforementioned?

    Read the article

  • Bash history handling with multiple terminals

    - by zetah
    I use mainly Terminator, and it's usually opened with 3 split terminal windows. I also use Gnome terminal for various reasons. I'm wondering how is bash history handled in this case as I sometimes miss previously issued commands when I run history For example, my prompt shows current bash history line (\!) and if I launch Terminator with 3 split terminal windows I get same history line (let's say 100) on all terminals. Which history will be saved? Also launching Gnome Terminal after using Terminator I get line 100 at startup regardless all commands issued before in Terminator

    Read the article

  • launching a program from bash causes bash to go to new prompt

    - by Dan Dman
    When I run a program from the console, e.g. me@box:~$ firefox I expect the console to log error messages (I think this is std out or std err?) and other items from the program, firefox in this case. But today I notice that bash just opens the program and goes to a new prompt, e.g. me@box:~$ firefox me@box:~$ How do I launch a program from bash such that error messages will be written to the console? Why is it that some programs operate this way by default and others (firefox) do not?

    Read the article

  • skipping a variable using while read in bash

    - by Aleksandar Ivanisevic
    i'm reading a few variables from a file using while read a b c; do (something) done < filename is there an elegant way to skip a variable (read in an empty value), i.e. if I want a=1 b= c=3, what should I write in the file? Right now i'm putting 1 "" 3 and then use b=$(echo $b | tr -d \" ) but this is pretty cumbersome, IMHO any ideas?

    Read the article

  • Problem with Bash script: 'declare: not found'

    - by Ashfame
    I had a script which was running fine but when I ran it today, it says declare: not found. I am using bash shell and path at the starting of the script is correct. Two flagged lines in my script are as follows: declare -a RESPONSE RESPONSE=($RESULT) It also says ( is unexpected but I guess that is coming up because of the first error. Worth mentioning point is when I type in declare directly works fine. declare | grep USER shows USER=ashfame USERNAME=ashfame values="$SVN_BASH_USERNAME"; So, whats wrong here?

    Read the article

  • Bash script throws, "syntax error near unexpected token `}'" when ran

    - by Tab00
    I am trying to write a script to monitor some battery statuses on a laptop running as a server. To accomplish this, I have already started to write this code: #! /bin/bash # A script to monitor battery statuses and send out email notifications #take care of looping the script for (( ; ; )) do #First, we check to see if the battery is present... if(cat /proc/acpi/battery/BAT0/state | grep 'present: *' == present: yes) { #Code to execute if battery IS present #No script needed for our application #you may add scripts to run } else { #if the battery IS NOT present, run this code sendemail -f [email protected] -t 214*******@txt.att.net -u NTA TV Alert -m "The battery from the computer is either missing, or removed. Please check ASAP." -s smtp.gmail.com -o tls=yes -xu [email protected] -xp *********** } #Second, we check into the current state of the battery if(cat /proc/acpi/battery/BAT0/state | grep 'charging state: *' == 'charging state: charging') { #Code to execute if battery is charging sendemail -f [email protected] -t 214*******@txt.att.net -u NTA TV Alert -m "The battery from the computer is charging. This MIGHT mean that something just happened" -s smtp.gmail.com -o tls=yes -xu [email protected] -xp *********** } #If it isn't charging, is it discharging? else if(cat /proc/acpi/battery/BAT0/state | grep 'charging state: *' == 'charging state: discharging') { #Code to run if the battery is discharging sendemail -f [email protected] -t 214*******@txt.att.net -u NTA TV Alert -m "The battery from the computer is discharging. This shouldn't be happening. Please check ASAP." -s smtp.gmail.com -o tls=yes -xu [email protected] -xp *********** } #If it isn't charging or discharging, is it charged? else if(cat /proc/acpi/battery/BAT0/state | grep 'charging state: *' == 'charging state: charged') { #Code to run if battery is charged } done I'm pretty sure that most of the other stuff works correctly, but I haven't been able to try it because it will not run. whenever I try and run the script, this is the error that I get: ./BatMon.sh: line 15: syntax error near unexpected token `}' ./BatMon.sh: ` }' is the error something super simple like a forgotten semicolon? Thanks -Tab00

    Read the article

  • Bash alias and bash function with several arguments

    - by sanemat
    I want to use both bash alias and bash function with several arguments. I emulate svn sub commands. $ svngrep -nr 'Foo' . $ svn grep -nr 'Foo' . My expectation is both act as below: grep --exclude='*.svn-*' --exclude='entries' -nr 'Foo' . But actual, only alias ('svngrep') does well, function ('svn grep') causes invalid option error. How to write my .bashrc? #~/.bashrc alias svngrep="grep --exclude='*.svn-*' --exclude='entries'" svn() { if [[ $1 == grep ]] then local remains=$(echo $@ | sed -e 's/grep//') command "$svngrep $remains" else command svn "$@" fi }

    Read the article

  • What does (Lua) game scripting mean?

    - by Gerenuk
    I've read that Lua is often used for embedded scripting and in particular game for scripting. I find it hard to picture how it is used exactly. Can you describe why and for which features and for which audience it is used? This questions isn't specifically addressing Lua, but rather any embedded scripting that serves a purpose similar to Lua scripting. Is it used for end-users to make custom adjustments? Is it used for game developers to speed up creation of game logic (levels, AI, ...)? Is it used to script game framework code since scripting can be faster? Basically I'm wondering how deep between plain configuration and framework logic such scripting usage goes. And how much scripting is done. A few configuration lines or a considerable amount?

    Read the article

  • Bash: command not found

    - by Alexandre Teles
    I have a script that needs to know the processor architecture. I'm doing this way: if [["$(uname -m)" = "x86_64"]]; then wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm else echo "Nossa! Você só pode usar 3,5GB de memória RAM. Que triste :( Vou baixar a versão 32bits pra você tá?" wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.rpm fi But when I execute the code, I receive: instala_chrome.sh: line 35: [[x86_64: command not found Anyone can help me to solve this? Thanks!

    Read the article

  • How to debug a .bash_profile

    - by Blankman
    I was updating my .bash_profile, and unfortunetly I made a few updates and now I am getting: env: bash: No such file or directory env: bash: No such file or directory env: bash: No such file or directory env: bash: No such file or directory env: bash: No such file or directory -bash: tar: command not found -bash: grep: command not found -bash: cat: command not found -bash: find: command not found -bash: dirname: command not found -bash: /preexec.sh.lib: No such file or directory -bash: preexec_install: command not found -bash: sed: command not found -bash: git: command not found My bash_profile actually pulls in other .sh files (sources them) so I am not exactly sure which modification may have caused this. Now if I even try and to a list of files, I get: >ls -bash: ls: command not found -bash: sed: command not found -bash: git: command not found Any tips on how to trace the source of the error, and how to be able to use the terminal for basic things like listing files etc?

    Read the article

  • Every command fails with "command not found" after changing .bash_profile?

    - by Blankman
    I was updating my .bash_profile, and unfortunetly I made a few updates and now I am getting: env: bash: No such file or directory env: bash: No such file or directory env: bash: No such file or directory env: bash: No such file or directory env: bash: No such file or directory -bash: tar: command not found -bash: grep: command not found -bash: cat: command not found -bash: find: command not found -bash: dirname: command not found -bash: /preexec.sh.lib: No such file or directory -bash: preexec_install: command not found -bash: sed: command not found -bash: git: command not found My bash_profile actually pulls in other .sh files (sources them) so I am not exactly sure which modification may have caused this. Now if I even try and to a list of files, I get: >ls -bash: ls: command not found -bash: sed: command not found -bash: git: command not found Any tips on how to trace the source of the error, and how to be able to use the terminal for basic things like listing files etc?

    Read the article

  • bitwise XOR a string in Bash

    - by ricky2002
    Hi. I am trying to accomplish a work in Bash scripting. I have a string which i want to XOR with my key. #!/bin/sh PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH teststring="abcdefghijklmnopqr" Now how do i XOR the value of teststring and store it in a variable using bash? Any help will be appreciated.

    Read the article

  • Is there a difference between "." and "source" in bash, after all?

    - by ysap
    I was looking for the difference between the "." and "source" builtin commands and a few sources (e.g., in this discussion, and the bash manpage) suggest that these are just the same. However, following a problem with environment variables, I conducted a test. I created a file testenv.sh that contains: #!/bin/bash echo $MY_VAR In the command prompt, I performed the following: > chmod +x testenv.sh > MY_VAR=12345 > ./testenv.sh > source testenv.sh 12345 > MY_VAR=12345 ./testenv.sh 12345 [note that the 1st form returned an empty string] So, this little experiment suggests that there is a difference after all, where for the "source" command, the child environment inherits all the variables from the parent one, where for the "." it does not. Am I missing something, or is this is an undocumented/deprecated feature of bash? [ GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu) ]

    Read the article

  • Dynamic case statement in bash

    - by infra.user
    Hi folks, I'm trying to figure out how to create a dynamic case statement in a bash script. For example, let's say I have the output of an awk statement with the following contents red green blue In this scenario, the output can change at any time. I'm trying to then execute different logic if a value is included in this awk output. So if the data above is in $list, then I'd conceptually like to do something like: case "${my_var}" in $list) ..... something_else) ..... esac I'm trying to use this to build a dynamic custom tab completion function (see http://www.debian-administration.org/article/An_introduction_to_bash_completion_part_2 for some background). Any ideas? Thanks.

    Read the article

  • How do I start bash in 13.04?

    - by Maik Klein
    I have a bash script that I need to execute. It seems that I can't run in in my terminal because it has a slightly different syntax. I could run the first file like bash ./configure but it produces a makefile that I can not use. If I try bash make it tells me that it can't execute make. How do I run this make file in bash? I tried cd /usr/bin ./bash but it tells me that it can't find bash. So how do I start bash?

    Read the article

  • Bash script to create mass series of directories

    - by Volomike
    I need to create a Bash script to go into every user's home folder, seek out a wp-content folder, create a directory uploads under it, and then chmod 0756 uploads. How do I achieve this? I imagine I need to use find with a regexp/regex, and then tell it to run another bash script on the results.

    Read the article

  • Unable to delete a file using bash script

    - by user3719091
    I'm having problems removing a file in a bash script. I saw the other post with the same problem but none of those solutions solved my problem. The bash script is an OP5 surveillance check and it calls an Expect process that saves a temporary file to the local drive which the bash script reads from. Once it has read the file and checked its status I would like to remove the temporary file. I'm pretty new to scripting so my script may not be as optimal as it can be. Either way it does the job except removing the file once it's done. I will post the entire code below: #!/bin/bash #GET FLAGS while getopts H:c:w: option do case "${option}" in H) HOSTADDRESS=${OPTARG};; c) CRITICAL=${OPTARG};; w) WARNING=${OPTARG};; esac done ./expect.vpn.check.sh $HOSTADDRESS #VARIABLES VPNCount=$(grep -o '[0-9]\+' $HOSTADDRESS.op5.vpn.results) # Check if the temporary results file exists if [ -f $HOSTADDRESS.op5.vpn.results ] then # If the file exist, Print "File Found" message echo Temporary results file exist. Analyze results. else # If the file does NOT exist, print "File NOT Found" message and send message to OP5 echo Temporary results file does NOT exist. Unable to analyze. # Exit with status Critical (exit code 2) exit 2 fi if [[ "$VPNCount" > $CRITICAL ]] then # If the amount of tunnels exceeds the critical threshold, echo out a warning message and current threshold and send warning to OP5 echo "The amount of VPN tunnels exceeds the critical threshold - ($VPNCount)" # Exit with status Critical (exit code 2) exit 2 elif [[ "$VPNCount" > $WARNING ]] then # If the amount of tunnels exceeds the warning threshold, echo out a warning message and current threshold and send warning to OP5 echo "The amount of VPN tunnels exceeds the warning threshold - ($VPNCount)" # Exit with status Warning (exit code 1) exit 1 else # The amount of tunnels do not exceed the warning threshold. # Print an OK message echo OK - $VPNCount # Exit with status OK exit 0 fi #Clean up temporary files. rm -f $HOSTADDRESS.op5.vpn.results I have tried the following solutions: Create a separate variable called TempFile that specifies the file. And specify that in the rm command. I tried creating another if statement similar to the one I use to verify that file exist and then rm the filename. I tried adding the complete name of the file (no variables, just plain text of the file) I can: Remove the file using the full name in both a separate script and directly in the CLI. Is there something in my script that locks the file that prevents me from removing it? I'm not sure what to try next. Thanks in advance!

    Read the article

  • Call 'script' command and exit it from within a bash script

    - by William Jamieson
    I'm using the linux 'script' command http://www.linuxcommand.org/man_pages/script1.html to log all input and output in an interactive bash script. At the moment I have to call the script command, then run my bash script, then exit. I want to run the script and exit commands from within the actual bash script itself. How can I do this? I've tried script -a but that doesn't work for interactive scripts. Any assistance would be greatly appreciated.

    Read the article

  • bash doesn't keep history

    - by yohbs
    I run Ubuntu 12.04, and for some reason bash does not keep my command history. the ~/.bash_history file contains only 3 commands that I typed a few months ago. How can I fix this? EDIT: here's the relevant content of my .bashrc: # ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples # If not running interactively, don't do anything [ -z "$PS1" ] && return # don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth # append to the history file, don't overwrite it shopt -s histappend # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=1000 HISTFILESIZE=2000

    Read the article

  • Need help fixing a strange path error in bash

    - by Evan
    UPDATE Ok, I found some errors in the path which I think I fixed, but now it's not running in any case - which for some reason I think is a step forward. Thanks for suggesting the following steps, here is their output: user@computer:~$ echo $PATH /usr/share/fsl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/matlab/bin:/usr/local/VoxBo/bin:/usr/local/itt/idl64/bin:/usr/local/afni/bin/:/usr/local/mricron:/usr/lib/voxbo/bin:/home/user/folder:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11/:/usr/games/:/usr/local/matlab/bin:/usr/local/VoxBo/bin/:/usr/local/itt/idl64/bin:/usr/local/afni/bin/:/usr/local/mricron/ user@computer:~$ typeset -p PATH declare -x PATH="/usr/share/fsl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/matlab/bin:/usr/local/VoxBo/bin:/usr/local/itt/idl64/bin:/usr/local/afni/bin/:/usr/local/mricron:/usr/lib/voxbo/bin:/home/user/folder:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11/:/usr/games/:/usr/local/matlab/bin:/usr/local/VoxBo/bin/:/usr/local/itt/idl64/bin:/usr/local/afni/bin/:/usr/local/mricron/" user@computer:~$ type app1 app1 is /home/user/folder/app1 user@computer:~$ type app2 app2 is /home/user/folder/app2 user@computer:~$ app1 bash: /home/user/folder/app1: No such file or directory user@computer:~$ app2 bash: /home/user/folder/app2: No such file or directory user@computer:~$ /home/user/folder/app1 bash: /home/user/folder/app1: No such file or directory user@computer:~$ /home/user/folder/app2 bash: /home/user/folder/app2: No such file or directory user@computer:~$ cd /home/user/folder user@computer:~/folder$ app1 bash: /home/user/folder/app1: No such file or directory user@computer:~/folder$ ./app1 bash: ./app1: No such file or directory user@computer:~/folder$ ./app2 bash: ./app2: No such file or directory user@computer:~/folder$ ls -l total 29384 -rwxr-xr-x 1 user user 14949776 2011-02-03 11:09 app1 -rwxr-xr-x 1 user user 15137300 2011-02-03 11:10 app2 user@computer:~/folder$ Thanks for everyone's input! ORIGINAL QUESTION I have two executable files I downloaded and am trying to add to the path. They are located in /home/user/folder and the specific files are /home/user/folder/app1 /home/user/folder/app2 Both app1 and app2 have the executable flag set to all (user, group, other). I can execute the files if I am in /home/user/folder and I execute these commands ./app1 ./app2 However I can't run them from elsewhere. I added this line to my .profile PATH="$PATH:/home/user/folder" and then sourced the path with . /home/user/.profile and I can see app1 and app2 when I use command completion (pressing tab). However here is what happens when I try to run app1 or app2 with the following commands (the following only shows 'app1' but the same is true of 'app2') user@comp:~$ app1 -bash: app1: command not found user@comp:~$ /home/user/folder/app1 -bash: app1: command not found user@comp:~/folder$ ./app1 (program runs) I'm stumped :), I must have missed something simple. Thanks for your help!!

    Read the article

  • I need to know the reasons why learning Linux Shell Scripting (BASH) benefits me as a PHP developer

    - by Ahmad Farouk
    I have been developing web sites/applications using the LAMP stack for almost 5 years. Currently I am interested to dig more into Linux OS, specifically BASH but from a web developer perspective, not from sys admin perspective. I am not intending to administrate Linux Servers. Only, I want to know, does learning shell scripting benefit me as a PHP developer? Does it make me a better, more skilled developer, or just its something irrelevant? Reasons, and examples are highly appreciated. Thanks in advance.

    Read the article

  • How do the environments of a standard Terminal command-line and a bash script differ?

    - by fred.bear
    I know there is something different about the environment of the Terminal command-line and the environment in a bash script, but I don't know what that difference is... Here is the example which finally led me to ask this quesiton; it may flush out some of the differences. I am trying to strip leading '0's from a number, with this command. var="000123"; var="${var##+(0)}" ; echo $var When I run this command from the Terminal's command-line, I get: 123 However, when I run it from within a script, it doesn't work; I get: 000123 I'm using Ubuntu 10.04, and tried all the following with the sam results: GNOME Terminal 2.30.2 Konsole 2.4.5 #!/bin/bash #!/bin/sh What is causing this difference? Even if some upgrade will make it work in scripts... I am trying to find out the what and why, so in future, I'll know what to look out for .

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >