Search Results

Search found 4967 results on 199 pages for 'bourne shell'.

Page 54/199 | < Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >

  • Bash: Quotes getting stripped when a command is passed as argument to a function

    - by Shoaibi
    I am trying to implement a dry run kind of mechanism for my script and facing the issue of quotes getting stripped off when a command is passed as an argument to a function and resulting in unexpected behavior. dry_run () { echo "$@" #printf '%q ' "$@" if [ "$DRY_RUN" ]; then return 0 fi "$@" } email_admin() { echo " Emailing admin" dry_run su - $target_username -c "cd $GIT_WORK_TREE && git log -1 -p|mail -s '$mail_subject' $admin_email" echo " Emailed" } Output is: su - webuser1 -c cd /home/webuser1/public_html && git log -1 -p|mail -s 'Git deployment on webuser1' [email protected] Expected: su - webuser1 -c "cd /home/webuser1/public_html && git log -1 -p|mail -s 'Git deployment on webuser1' [email protected]" With printf enabled instead of echo: su - webuser1 -c cd\ /home/webuser1/public_html\ \&\&\ git\ log\ -1\ -p\|mail\ -s\ \'Git\ deployment\ on\ webuser1\'\ [email protected] Result: su: invalid option -- 1 That shouldn't be the case if quotes remained where they were inserted. I have also tried using "eval", not much difference. If i remove the dry_run call in email_admin and then run script, it work great.

    Read the article

  • Discrepancy in file size on disk and ls output

    - by smokinguns
    I have a script that checks for gzipped file sizes greater than 1MB and outputs files along with their sizes as a report. This is the code: myReport=`ls -ltrh "$somePath" | egrep '\.gz$' | awk '{print $9,"=>",$5}'` # Count files that exceed 1MB oversizeFiles=`find "$somePath" -maxdepth 1 -size +1M -iname "*.gz" -print0 | xargs -0 ls -lh | wc -l` if [ $oversizeFiles -eq 0 ];then status="PASS" else status="CHECK FAILED. FOUND FILES GREATER THAN 1MB" fi echo -e $status"\n"$myReport The problem is that ls command outputs the files sizes as 1.0MB in the report but the status is "FAIL" as "$oversizeFiles" variable's value is 2. I checked the file sizes on disk and 2 files are 1.1MB. Why this discrepancy? How should I modify the script so that I can generate an accurate report? BTW, I'm on a Mac. Here is what man page for "find" says on my Mac OSX: -size n[ckMGTP] True if the file's size, rounded up, in 512-byte blocks is n. If n is followed by a c,then the primary is true if the file's size is n bytes (characters). Similarly if n is followed by a scale indicator then the file's size is compared to n scaled as: k kilobytes (1024 bytes) M megabytes (1024 kilobytes) G gigabytes (1024 megabytes) T terabytes (1024 gigabytes) P petabytes (1024 terabytes)

    Read the article

  • my.cnf in server directory, why

    - by Mellon
    On my Ubuntu machine, I have installed MySQL . I notice that there are /etc/my.cnf file which contain the content (only two lines): innodb_buffer_pool_size = 1G max_allowed_packet = 512M While there is also /etc/mysql/my.cnf with a long content like: # The MySQL database server configuration file. ... ... For me, it looks like both are configurations for MySQL server, but Why there are two my.cnf in different locations, can't the content to be merged to one my.cnf ? What is the purpose to have seperate my.cnf for MySQL server ?

    Read the article

  • Automatically mount partition when needed

    - by David Parunakian
    Hello, Can anyone suggest a method of mounting a partition (e.g. an NFS share) when a user changes into the directory it is set to be mounted to, and not on the system startup? So far I've been unable to propose such a method, aside from editing BASH built-in cd implementation and forcing an fstab/mtab check before the working directory is actually changed.

    Read the article

  • download and process a file by ftp at set intervals, with error handling, rescheduling and status messages

    - by compound eye
    I want to download a data file from a remote ftp server to my machine at regular intervals. Once the file is downloaded I want to call another script which will process the file. My development machine is mac os x, the eventual deployment environment is linux. What's would be the stock standard way to automate this? I know I can use cron to schedule curl to download and to run a script that will process the downloaded file at regular intervals, and I know could write a slightly more complex script or an application that would do this and add error handling, rescheduling and sending status emails. But one of my requirements for this project is to write as little custom code as possible, instead I should try to use standard, tried and true existing tools, and if I do have to write code, to try and write the most straightforward code possible. The reason for this is the code will potentially be installed on a large number of machines, all of which will need to be tweaked, customised and maintained by different people, long after I am gone from the project, so the intention is to use well documented, well supported tools as much as possible. This seems such a common task, there must be tools and scripts all over the internet, written by people who have carefully considered everything that could possibly go wrong when you need to download and process a file from a remote server at regular intervals, with error handling, rescheduling and sending status messages. Is that what Expect is for? What would you recommend? (the system will be downloading weather prediction data every six hours, so that the system can prepare in the event of bad weather warnings)

    Read the article

  • Diff and ignore lines missing in one file

    - by Millianz
    I want to diff two files and ignore lines that are present in one file but missing in the other. For example File1: foo bar baz bat File2: foo ball bat I'm currently running the following diff command diff File1 File2 --changed-group-format='%>' --unchanged-group-format='' Which in this case would produce bar baz as the output, i.e. only missing or conflicting lines. I would like to only print conflicting lines, i.e. ignore cases where one line is missing from File2 and is present in File1 (not the other way around). Is there any way to do something like this using diff or do I have to resort to other tools? If so, what would you recommend?

    Read the article

  • Start Chrome by command line, but adding some arguments to make it login into your Google account automatically

    - by jim
    Is there a way to start Chrome calling it from the command line (using Linux), but providing it some argument to make it login into some Google account automatically? I'm looking for something like google-chrome -account foo -pass bar that I can easily put in a bash script later. A little background: I have a laptop connected to my TV, which is currently using just a mouse for user interaction. There's no google account logged in by default, and that's the way I want to keep it, so my kids can't come across videos and pictures in google and youtube that they are not supposed to see (e.g.: adult content, or anything marked as not appropriate for kids by the google's safe search filters). The bad thing about this is that there are some music videos in youtube that requires you to be logged in to see, usually those we (the adults) used to sing when playing karaoke... as the only input available is a mouse, I'm looking for a way to start with my google account without having to type the whole thing usin the on-screen keyboard. You may think "Why you can't use the keyboard, if the laptop is right there?". Well, it's in a kind of uncomfortable position - too high for me without a chair or something, as it's right above the furniture in where the TV is located. Is there a way to make this scriptable? If not, do you know any other workaround? Note: using the remember me after logging off or alike options are discarded, as the safe-search chrome version must be always the default version to run.

    Read the article

  • Problems with Startup after Script runs to Shutdown Windows 7 PC

    - by Toby Allen
    I have a simple .bat script to shutdown a kiosk style machine in our work shutdown -h -f this hibernates the machine and I have it running each evening as a scheduled job. However my problem comes when I turn the machine on again. The first time I press power it starts up and then immediately hibernates again, like it runs the script a second time. the second time I press power it stays up. Any suggestions on how I can avoid this?

    Read the article

  • Over writing output to a text file

    - by Naveen Gamage
    I'm trying to write wget command's output to a text file, but it always appends to the text file. #!/bin/sh download() { local url=$1 echo -n " " wget --progress=dot $url 2>&1 | grep --line-buffered "%" | \ sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}' echo " DONE" } file="$1" echo -n "Downloading $file:" download "$file" > file.log I tried using using > won't work, where am I doing wrong?

    Read the article

  • Tab Auto-Completion in Mac OS X when using sftp in terminal

    - by AlanTuring
    i have been getting very frustrated lately since the readline functionality has been removed from MacOSX and Tab Auto-Completion doesn't work anymore. So i was wondering if anyone knew a good alternative to use that i could install so i can tab auto-complete files when sftp'd in. I heard that with-readline is a good option for this. If so, how do i get an alias sftp = with-readline sftp to work? I would like to do the same with any other option that isn't with-readline, so i don't have to assign an alias each time i set up a session. I am using Mac OS X 10.8(Mountain Lion) with Homebrew installed. Thanks in advance to anyone who can help me.

    Read the article

  • Using SSH, transfer webURL to remote machine

    - by AlanTuring
    Hi so i was doing some research in the library so i could use some pictures later on my Desktop computer in my room. I have space on my Lab account which i usually SSH into, and i was wondering if URL's can be directly transferred over to a remote machine and saved on the hard disk. I was thinking something like this: scp http://click.si.edu/images/truncatedurl.jpg /home3/etc.../filename.jpg is this possible? Thanks in advance.

    Read the article

  • Accidental Extract Location - How to Clean Up?

    - by Gordon
    Sometimes I will do a command such as unzip tons_of_files.zip And I will forget to put a -d to point to a subdirectory. This causes the current folder to get filled with tons of files that are intermixed with the existing files. What is the best way to remove all these new files and/or move them to a new directory? I want to avoid having to manually examine the directory and determine if the file was part of the archive or was already present.

    Read the article

  • UTF-8 locale portability (and ssh)

    - by kine
    I spend a lot of my time sshed into various machines, all of which are different (some are embedded, some run Linux, some run BSD, &c.). On my own local machines, however, i use OS X, which of course has a userland based on FreeBSD. My locale on those machines is set to en_GB.UTF-8, which is one of the available options: % echo `sw_vers` ProductName: Mac OS X ProductVersion: 10.8.2 BuildVersion: 12C60 % locale -a | grep -i 'en_gb.utf' en_GB.UTF-8 Several of the more-capable Linux systems i use appear to have an equivalent option, but i note that on Linux the name is slightly different: % lsb_release -d Description: Debian GNU/Linux 6.0.3 (squeeze) % locale -a | grep -i 'en_gb.utf' en_GB.utf8 This makes me wonder: When i ssh into a Linux machine from my Mac, and it forwards all of my LC_* variables with that 'UTF-8' suffix, does that Linux machine even understand what is being asked of it? Or is it just falling back to some other locale? In either case, what is the mechanism behind its behaviour, and is it dependent on any particular set-up (e.g., will i see the same behaviour on a BusyBox-based system as on a GNU-based one)?

    Read the article

  • what to do when ctrl-c can't kill a process?

    - by Dustin Boswell
    Ctrl-c doesn't always work to kill the current process (for instance, if that process is busy in certain network operations). In that case, you just see "^C" by your cursor, and can't do much else. What's the easiest way to force that process to die now without losing my terminal? Summary of answers below: Usually, you can Ctrl-z to put the process to sleep, and then do "kill -9 process-pid", where you find the process's pid with 'ps' and other tools. On Bash (and possibly other shells) you can do "kill -9 %1" (or '%N' in general) which is easier. If Ctrl-z doesn't work, you'll have to open another terminal and kill from there.

    Read the article

  • Files copying between servers by creation time

    - by driftux
    My bash scripting knowledge is very weak that's why I'm asking help here. What is the most effective bash script according to performance to find and copy files from one LINUX server to another using specifications described below. I need to get a bash script which finds only new files created in server A in directories with name "Z" between interval from 0 to 10 minutes ago. Then transfer them to server B. I think it can be done by formatting a query and executing it for each founded new file "scp /X/Y.../Z/file root@hostname:/X/Y.../Z/" If script finds no such remote path on server B it will continue copying second file which directory exists. File should be copied with permissions, group, owner and creation time. X/Y... are various directories path. I want setup a cron job to execute this script every 10 minutes. So the performance is very important in this case. Thank you.

    Read the article

  • In Bash, how can I obtain the directory path from the previous command's last argument

    - by Beaming Mel-Bin
    I frequently have to do this. For example: $ vim /etc/pam.d/sudo $ vim /etc/pam.d/sudo-i $ cd /etc/pam.d/ # Figure I should just go to the directory Now, is there a way I could obtain the directory of the last argument when it's a file path? I'm asking this cause I recently became aware of the $_ variable that has become useful. Was wondering if there's some other commandline fu that might come in handy.

    Read the article

  • PuTTY - Server Unexpectedly Closed Network Connection

    - by Austin
    I have two servers that I have been able to connect fine as s1.website.com and s2.website.com I connected to s1.website.com earlier today without any issues, however, when I connected to s2.website.com it gave me the "Server Unexpectedly Closed Network Connection" I have researched this elsewhere and someone concluded it to a "brute force attempt" However, I know this is not the case. If anyone else has had this issue please let me know. Thanks

    Read the article

  • Cron process not starting

    - by vkris
    I have an ec2 image created with cron jobs. These jobs fail to run; I discovered the cron process in itself has not started. So, I included /usr/sbin/cron in /etc/rc.d/rc.local and created another image. But still for some reason the cron process does not start on bootup. If I restart the machine, the cron process runs. It doesn't run when it boots up! Any reason why this is happening? Also, is there any other alternatives for this ?

    Read the article

  • Get a script to run at startup (linux)

    - by Dan Graves
    I am trying to get a simple script to run automatically at startup. A friend told me to do this but it did not work. Could someone take a look to see what it is missing? *(Also I am brand new to linux, so this is pretty foreign to me) Here is what I was told to do: In terminal sudo nano /etc/init.d/obabp.sh Then enter this text: #!/bin/bash sudo python /home/pi/gits/RPi-OBABP/src/obabp.py save file and then $ sudo chmod +x /etc/init.d/obabp.sh $ sudo shutdown -r now

    Read the article

  • Unix: sleep until the specified time

    - by aix
    Is there a (semi-)standard Unix command that would sleep until the time specified on its command line? In other words, I am looking for something similar to sleep that would take wakeup time rather than duration. For example: sleeptill 05:00:00 I can code something up but would rather not re-invent the wheel if there's already something out there. Bonus question: it would be great if it could take the timezone (as in sleeptill 05:00:00 America/New_York). edit Due to the nature of what I am doing, I am looking for a "sleep until T" rather than "run command at T" solution. edit For the avoidance of doubt, if I run the command at 18:00 and tell it to wake up at 17:00, I expect it to sleep for 23 hours (or, in some corner cases having to do with daylight savings time, for 22 or 24 hours.)

    Read the article

  • BASH - Run command for each line in output of previous command

    - by user1582375
    All, I am want to request all network services using: networksetup -listallnetworkservices I then want to run the below command for each line in produced from the above command: networksetup -setautoproxyurl "A LINE FROM ABOVE" http://etc... Adiitonally, I only want to issue the setautoproxyurl command for service with "Ethernet" or "Wi-Fi" in the name networksetup -listallnetworkservices | while read line; do networksetup -setautoproxy $line http://etc...

    Read the article

  • Connect to MySQL trough command line without need root password

    - by ReynierPM
    I'm building a Bash script for some tasks. One of those tasks is create a MySQL DB from within the same bash script. What I'm doing right now is creating two vars: one for store user name and the other for store password. This is the relevant part of my script: MYSQL_USER=root MYSQL_PASS=mypass_goes_here touch /tmp/$PROY.sql && echo "CREATE DATABASE $DB_NAME;" > /tmp/script.sql mysql --user=$MYSQL_USER --password="$MYSQL_PASS" < /tmp/script.sql rm -rf /tmp/script.sql But always get a error saying access denied for user root with NO PASSWORD, what I'm doing wrong? I need to do the same for PostgreSQL, any help? Regards and thanks in advance

    Read the article

< Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >