Search Results

Search found 6758 results on 271 pages for 'shell exec'.

Page 80/271 | < Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >

  • Validating parameters to a bash script

    - by nickf
    I'm a total newbie to doing any bash scripting, but I came up with a basic one to help automate the process of removing a number of folders as they become unneeded. #!/bin/bash rm -rf ~/myfolder1/$1/anotherfolder rm -rf ~/myfolder2/$1/yetanotherfolder rm -rf ~/myfolder3/$1/thisisafolder This is evoked like so: ./myscript.sh <{id-number}> The problem is that if you forget to type in the id-number (as I did just then), then it could potentially delete a lot of things that you really don't want deleted. Is there a way you can add any form of validation to the command line parameters? In my case, it'd be good to check that a) there is one parameter, b) it's numerical, and c) that folder exists; before continuing with the script.

    Read the article

  • OSX launchctl programmatically as root

    - by Lukas1
    I'm trying to start samba service using launchctl from OSX app as root, but I get error status -60031. I can run without problems the command in Terminal: sudo launchctl load -F /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist` In the objective-c code, I'm using (I know it's deprecated, but that really shouldn't be the issue here) AuthorizationExecuteWithPrivileges method. Here's the code: NSString *command = @"launchctl"; // Conversion of NSArray args to char** args here (not relevant part of the code) OSStatus authStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &_authRef); if (authStatus != errAuthorizationSuccess) { NSLog(@"Failed to create application authorization: %d", (int)authStatus); return; } FILE* pipe = NULL; AuthorizationFlags flags = kAuthorizationFlagDefaults; AuthorizationItem right = {kAuthorizationRightExecute, 0, NULL, 0}; AuthorizationRights rights = {1, &right}; // Call AuthorizationCopyRights to determine or extend the allowable rights. OSStatus stat = AuthorizationCopyRights(_authRef, &rights, NULL, flags, NULL); if (stat != errAuthorizationSuccess) { NSLog(@"Copy Rights Unsuccessful: %d", (int)stat); return; } OSStatus status = AuthorizationExecuteWithPrivileges(_authRef, command.UTF8String, flags, args, &pipe); if (status != errAuthorizationSuccess) { NSLog(@"Error executing command %@ with status %d", command, status); } else { // some other stuff } I have also tried using different flags then kAuthorizationFlagDefaults, but that led to either the same problem or error code -60011 - invalid flags. What am I doing wrong here, please?

    Read the article

  • Bash command that prints a message on stderr

    - by Salman A
    I want to know if there is a built-in BASH command that prints some text on stderr, just like the echo command that prints text on stdout. I don't want to use temporary io-redirection. I use a built-in command to generate an error on stderr such as ls --asdf (ls: unrecognized option '--asdf') but I want something neater,

    Read the article

  • Batch & log files

    - by Mat
    Hi All, Please help!!! ;) I have a problem with this code in a batch file (Linux): Mil=`date +"%Y%m%d%H%M%S"` batch=`echo "${DatMusic}"` TabimportEnteteMusic="importentetemusic.dat" { grep '^ENTETE' ${IMPORT}/${DatMusic} > ${IMPORT}/$TabimportEnteteMusic mysql -u basemine --password="basemine" -D basemine -e "delete from importmusic;" mysql -u basemine --password="basemine" -D basemine -e "delete from importentetemusic;" } >> $TRACES/batch/$Mil.$batch.log 2>&1 When I run this batch, its answer is: /home/mmoine/sgbd_mysql/batch/importMusic.sh: line 51: /batch/20100319160018.afce01aa.cr.log: Aucun fichier ou répertoire de ce type (in english, I suppose: "No files or Directory found") So, please, how can I put all generated messages in this log file? Thanks for your answers. Sorry for my english ;)

    Read the article

  • grep options (unix)

    - by lego69
    hello everyone, can You explain please, can grep pick rows if at least one element from the list appeared, for exmaple grep "hello world" file1 grep must give me all rows which have or word hello or world or both of them, thanks in advance

    Read the article

  • What does explorer use to open a file?

    - by dauphic
    I'm attempting to hook into whatever explorer calls when a file is opened (double-click, context menu open, etc.), however I can't figure out which function that is. Originally, I thought it was ShellExecute, as that does the same thing as far as I can tell, but after hooking into it I learned that it's only used when a new explorer window is opened. Any ideas which function I should be hooking?

    Read the article

  • Run C or C++ file as a script

    - by Brendan Long
    So this is probably a long shot, but is there any way to run a C or C++ file as a script? I tried: #!/usr/bin/gcc main.c -o main; ./main int main(){ return 0; } But it says: ./main.c:1:2: error: invalid preprocessing directive #!

    Read the article

  • how to delete a line from file using awk filtered by some string

    - by embedded
    I have a file delimited by space. I need to write an awk command that receives a host name argument and it should replace the host name if it already defined in the file. It must be a full match not partially - if the file contains this host name: localhost searching for "ho" will fail and it will be added to the end of the file. another option is a delete: again awk receives host name argument and it should remove it from the file if exists. This is what I have so far: (It needs some enhancements) if [ "$DELETE_FLAG" == "" ]; then # In this case the entry should be added or updated # if clause deals with updating an existing entry # END clause deals with adding a new entry awk -F"[ ]" "BEGIN { found = 0;} \ { \ if ($2 == $HOST_NAME) { \ print \"$IP_ADDRESS $HOST_NAME\"; \ found = 1; \ } else { \ print \$0; \ } \ } \ END { \ if (found == 0) { \ print \"$IP_ADDRESS $HOST_NAME\"; } \ } " \ /etc/hosts > /etc/temp_hosts else # Delete an existing entry awk -F'[ ]' '{if($2 != $HOST_NAME) { print $0} }' /etc/hosts > /etc/temp_hosts fi Thanks

    Read the article

  • start /B doesn't start the task

    - by Fractaliste
    I'm currently launching an asynchronous job with PHP to perform some tests. To make it work, I found on SO some tips, like the use of popen and start: $commande = "testu.bat"; $pid = popen('start /B ' . $commande, 'r'); $status = pclose($pid); The testu.bat's folder is in my user PATH. This script performs some task, and to control it's execution, it should generates a log file, but I never get it. Whereas if I just remove the /B option, it works fine and I get my log file. Did I miss something about background execution? How can I catch the error informations when it is running in the background?

    Read the article

  • Get part of a string of part of regular expression?

    - by Buttink
    Im trying to make a script that will go into a directory and run my own application with each file matching a regular expression, specifically "Test[0-9]*.txt". My input filenames look like this "TestXX.txt". Now, I could just use cut and chop off the Test and .txt, but how would I do this if XX wasn't predefined to be 2 numbers? What would I do if i had "Test1.txt" ... "Test10.txt"? In other words, How would I get the [0-9]* part? Just so you know, I want to be able to make a OutputXX.txt :)

    Read the article

  • sed 's/this/that/' -- ignoring g but still replace entire file

    - by lakshmipathi
    as title said, Im trying to change only the first occurrence of word.By using sed 's/this/that/' file.txt though i'm not using g option it replace entire file. How to fix this.? UPDATE: $ cat file.txt first line this this this this $ sed -e '1s/this/that/;t' file.txt first line this // ------> I want to change only this "this" to "that" :) this this this

    Read the article

  • SVN: Recurisvely add files?

    - by Mark
    I'm trying svn add *.py --force As the documentation suggests, but I know for a fact it's missing files nested in deeper folders. Why? Is there a standard way to do this with other unix commands too? */*.py will nab a few more files, but it's kind of a pain in the butt to do this for every possible depth.

    Read the article

  • Bash Scripting: I want to open a set of .html files, and add line before html tag

    - by Bashn00b
    Hi guys, I have a set of .php files in a folder, I want to add text just before these lines: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" > What i want is to insert just before these lines in the html file. So just want to prepend that file before each docType declaration. However the DOCTYPE declaration is never on line 1, as there is loads of php lines before. I have this current script (where FE is the folder containing all the scripts i want to edit): for file in ${fe}*; do echo "$file" done Thanks,

    Read the article

  • strip version from package name using Bash

    - by cd1
    hi, I'm trying to strip the version out of a package name using only Bash. I have one solution but I don't think that's the best one available, so I'd like to know if there's a better way to do it. by better I mean cleaner, easier to understand. suppose I have the string "my-program-1.0" and I want only "my-program". my current solution is: #!/bin/bash PROGRAM_FULL="my-program-1.0" INDEX_OF_LAST_CHARACTER=`awk '{print match($0, "[A-Za-z0-9]-[0-9]")} <<< $PROGRAM_FULL` PROGRAM_NAME=`cut -c -$INDEX_OF_LAST_CHARACTER <<< $PROGRAM_FULL` actually, the "package name" syntax is an RPM file name, if it matters. thanks!

    Read the article

  • Autorun a removable device in Linux

    - by Zloy Smiertniy
    I have a removable device setup so it autoruns when plugged into a Windows machine and pops up a message giving the owner's information, so it can be returned if lost. Is there a way to do this in Linux as well? It doesn't need to be complex, it can be an option in a right-click menu, or a splashscreen, or anything.

    Read the article

  • Sed-replacing a pattern

    - by grails_enthu
    I have below code: <td nowrap="nowrap" width="74"> <p align="center">server1</p> </td> <td nowrap="nowrap" width="74"> <p align="center">server2</p> </td> and so on.I want to get output as: <td nowrap="nowrap" width="74">server1</td> <td nowrap="nowrap" width="74">server2</td> What should be my approach?Say for example the file is server.html I have done something like this: sed "s/<p align="center">*</p>/*/" -i server.html But its not working.

    Read the article

  • How to delete "-" file from svn?

    - by ~brzeti
    Accidentally I have created file "-" (just a minus) in a directory and commited it. I have to delete it because its causing error on other machines: svn: Can't convert string from 'UTF-8' to native encoding: svn: ?\226?\128?\147 I can remove it from local directory using "rm -i *" or with python "os.remove('\xe2\x80\x93')" but those methods do not work with "svn rm". How to delete such file from svn repository?

    Read the article

  • grep value inside a variable pointing to other variable

    - by Joice
    using : ksh *abc = 1 efg = 2 hgd = 3 not known to me * say if i have Value="abc efg hgd" abc efg hgd all contains some value which i dnt know. Now I want to grep the value contained inside abc. like for i in $Value do grep "echo $(($((echo $i | cut -d'|' -f2))))" done this grep should look for the value inside abc efg hgd grep 1 grep 2 grep 3

    Read the article

  • Linux How to print all the files with the same prefix after searching for them?

    - by Alyx
    I need to search through a directory which contains many sub directories, each which contain files. The files read as follows question1234_01, where 1234 are random digits and the suffix _01 is the number of messages that contain the prefix, meaning they are apart of the same continuing thread. find . -name 'quest*' | cut -d_ -f1 | awk '{print $1}' | uniq -c | sort -n example output: 1 quest1234 10 quest1523 This searches for all the files then sorts them in order. What I want to do is print all the files which end up having the most occurrences, in my example the one with 10 matches. So it should only output quest1523_01 - 11

    Read the article

  • how to find and add a string to a file in linux

    - by user2951644
    How can I check a file for a string if missing the string automatically add it for example Input Input file test.txt this is a test text for testing purpose this is a test for testing purpose this is a test for testing purpose this is a test text for testing purpose I would like to add "text" to all the lines Desired Output this is a test text for testing purpose this is a test text for testing purpose this is a test text for testing purpose this is a test text for testing purpose Is it possible? many thanks in advance Hi guys thanks for all the help, for my case is not that simple. I wont know which line will be different and in the middle string it will not only have a single string. i will give a clearer case Input file test.txt Group: IT_DEPT,VIP Role: Viewer Dept: IT Group: IT_DEPT,VIP Dept: IT Group: FINANCE LOAN VIEWER Role: Viewer Dept: FINANCE Group: FINANCE LOAN VIEWER Dept: FINANCE Desired output file test2.txt Group: IT_DEPT,VIP Role: Viewer Dept: IT Group: IT_DEPT,VIP Role: - Dept: IT Group: FINANCE LOAN VIEWER Role: Viewer Dept: FINANCE Group: FINANCE LOAN VIEWER Role: - Dept: FINANCE So those that are missing "Role:" will be added "Role: - ", hope this clear things out, thanks in advance again

    Read the article

  • Find -type d with no subfolders

    - by titatom
    Good morning ! This is a simple one I believe, but I am still a noob :) I am trying to find all folders with a certain name. I am able to do this with the command find /path/to/look/in/ -type d | grep .texturedata The output gives me lots of folders like this : /path/to/look/in/.texturedata/v037/animBMP But I would like it to stop at .texturedata : /path/to/look/in/.texturedata/ I have hundreds of these paths and would like to lock them down by piping the output of grep into chmod 000 I was given a command with the argument -dpe once, but I have no idea what it does and the Internet has not be able to help me determine it's usage Thanks you very much for your help !

    Read the article

< Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >