Search Results

Search found 6936 results on 278 pages for 'shell scripting'.

Page 21/278 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • Problems with making a simple UNIX shell

    - by Kodemax
    Hai, I am trying to create a simple shell in UNIX. I read a lot and found that everybody uses the strtok a lot. But i want to do without any special functions. So i wrote the code but i cant seem to get it to work. Can anybody point out what i am doing wrong here? void process(char**); int arg_count; char **splitcommand(char* input) { char temp[81][81] ,*cmdptr[40]; int k,done=0,no=0,arg_count=0; for(int i=0 ; input[i] != '\0' ; i++) { k=0; while(1) { if(input[i] == ' ') { arg_count++; break; } if(input[i] == '\0') { arg_count++; done = 1; break; } temp[arg_count][k++] = input[i++]; } temp[arg_count][k++] = '\0'; if(done == 1) { break; } } for(int i=0 ; i<arg_count ; i++) { cmdptr[i] = temp[i]; cout<<endl; } cout<<endl; } void process(char* cmd[]) { int pid = fork(); if(pid < 0) { cout << "Fork Failed" << endl; exit(-1); } else if( pid == 0) { cout<<endl<<"in pid"; execvp(cmd[0], cmd); } else { wait(NULL); cout << "Job's Done" << endl; } } int main() { cout<<"Welcome to shell !!!!!!!!!!!"<<endl; char input[81]; cin.getline(input,81); splitcommand(input); }

    Read the article

  • How to compare two "not integer" values in shell script

    - by Reem
    I had to do a division in shell script and the best way was: result1=`echo "scale=3; ($var1 / $total) * 100"| bc -l` result2=`echo "scale=3; ($var2 / $total) * 100"| bc -l` but I want to compare the values of $result1 and $result2 Using if test $result1 -lt $result2 or if [ $result1 -gt $result2 ] didn't work :( Any idea how to do that?

    Read the article

  • Executing Shell Scripts from the OS X Dock?

    - by Wilco
    I'm sure the answer is ridiculously obvious, but so far Google hasn't been very helpful. How do I set up a shell script to execute from the dock? It seems that simply creating a shortcut will open the file in my editor. Is there a flag I need to set somewhere to tell it to run instead of opening it for editing?

    Read the article

  • Command passed as argument to shell script

    - by raj_arni
    Hi, I want to pass a command to a shell script. This command is a grep command. While executing I am getting the following errors, please help: myscript.sh "egrep 'ERROR|FATAL' \*20100428\*.log | grep -v aString" myscript.sh is a simple script: #!/bin/ksh cd log $1 the errors are: egrep: can't open | egrep: can't open grep egrep: can't open -v egrep: can't open aString Error is because egrap sees |, grep, -v and aString as arguments.

    Read the article

  • unix shell, redirect output but keep on stdin

    - by Mike
    I'd like to have a shell script redirect stdout of a child process in the following manner Redirect stdout to a file Display the output of the process in real time I know I could do something like #!/bin/sh ./child > file cat file But that would not display stdout in real time. For instance, if the child was #!/bin/sh echo 1 sleep 1 echo 2 The user would see "1" and "2" printed at the same time

    Read the article

  • Copy/Paste in emacs ansi-term shell

    - by user130208
    I have configured my emacs to run zsh shell within ansi-term. However, copy/paste no longer works i.e. nothing is getting pasted from kill-ring to the terminal. Changing the TERM to vt100, or eterm doesn't solve the problem. Would appreciate any ideas or solution. Thanks Sandeep

    Read the article

  • shell script array length

    - by Dipro Sen
    I assume arguments to my shell scripts willbe ./x.sh subject N file1 file2 fileN So I am splicing argv from 3 till end candidates=${@:3} now I want to check whether length of candidates is same as given N I am trying with echo $((${#candidates[@]})) which is always returning 1. I can do echo "$#-2" | bc but, I shouldn't I be able to get array size ? I can use bc to do integer comparison. but I've to know the size of `candidates array which I am not getting properly.

    Read the article

  • Php/Shell remote SVN tarballs

    - by Tom J Nowell
    I'd like to set up daily tarballs/zip archives on my host for an SVN of a related project. I do not have access to their server, however they do have a publicly accessible SVN. How would I grab this SVN and build archives with minimal load ( dreamhost shared ), via Cron task + php/shell script?

    Read the article

  • Exclude specific filename from shell globbing

    - by Alsciende
    Hi, I want to excluse a specific filename (say, fubar.log) from a shell (bash) globbing string, *.log. Nothing of what I tried seems to work, because globbing doesn't use the standard RE set. Test case : the directory contains fubar.log fubaz.log barbaz.log text.txt and only fubaz.log barbaz.log must be expanded by the glob.

    Read the article

  • Calling applescript from shell script using admin previleges

    - by Nir
    I'm running a shell script that runs an installation program (by ViseX) and selects different items in the installer through a list. The installer needs administrator privileges to run properly, but I don't want to use sudo. Here's the applescript I'm using: osascript <<-END tell application "$1" with timeout of 8 * 3600 seconds activate Select "$2" DoInstall end timeout end tell END

    Read the article

  • bash shell date parsing, start with specifc date and loop through each day in month

    - by Joe Stein
    Hi, I need to create a bash shell script starting with a day and then loop through each subsequent day formatting that output as %Y_%m_d I figure i can submit a start day and then another param for the number of days. My issue/question is how to set a DATE (that is not now) and then add a day. so my input would be 2010_04_01 6 my output would be 2010_04_01 2010_04_02 2010_04_03 2010_04_04 2010_04_05 2010_04_06 Thanks

    Read the article

  • How to manipulate a string, variable in shell

    - by user558134
    Hei everyone! I have this variable in shell containing paths separated by a space: LINE="/path/to/manipulate1 /path/to/manipulate2" I want to add additional path string in the beginning of the string and as well right after the space so that the variable will have the result something like this: LINE="/additional/path1/to/path/to/manipulate1 additional/path2/to/path/to/manipulate2" Any help appreciated Thanks in advance

    Read the article

  • Pie chart of *nix shell use [closed]

    - by hayk.mart
    I've encountered a situation where it would be very helpful to know the breakdown of shell use by percentage. For example, I'm looking for something like bash: X%, sh: Y%, csh, tcsh, zsh, ksh, dash, etc.. Obviously, I know there are several complications - multiple shells, the definition of "use", uncertainty and so forth, but I would like to see an informed answer derived from actual data and based on some stated metric, even if the result could be horribly wrong. Bonus if there is historical data demonstrating a shift in preferences.

    Read the article

  • writing a shell script if statement to check for directory

    - by user1553248
    I need to write a script that will recreate my opt folder if it gets deleted when I remove a package from it. Here's a link to my previous post: dpkg remove to stop processes Now, the issue I'm running into could be better described here: http://lists.debian.org/debian-devel/2006/03/msg00242.html I was thinking of just adding a postrem script which checks if an opt directory exists, and if not, creates one. My experience with shell scripts is pretty limited though..

    Read the article

  • Optimizing grep (or using AWK) in a shell script

    - by Ode
    Hi - In my shell script, I am trying to search using terms found in a $sourcefile against the same $targetfile over and over. My $sourcefile is formatted as such: pattern1 pattern2 etc... The inefficient loop I have to search with is: for line in $(< $sourcefile);do fgrep $line $targetfile | fgrep "RID" >> $outputfile done I understand it would be possible to improve this by either loading the whole $targetfile into memory, or perhaps by using AWK? Thanks

    Read the article

  • shell script problem: does not work on the terminal, but works in a script

    - by jrharshath
    Hi, I was playing with shell scripting, when a strange thing happened. I need someone to explain it. I have a file 'infile', contents: line one line2 third line last a test script test.sh, contents: read var1 echo $var1 i executed: cat infile | ./test.sh output was line one Then I did: cat infile | read var1 echo $var1 Result: a blank line. I even tried cat infile | read var1; echo $var1; same result. why does this happen?

    Read the article

  • shell_exec() in PHP

    - by Amar Ravikumar
    <?php // Execute a shell script $dump = shell_exec('bigfile.sh'); // This script takes some 10s to complete execution print_r($dump); // Dump log to screen ?> When the script above is executed from the browser, it loads for 10s and the dumps the output of the script to the screen. This is, of course, normal. But if I want the data written to STDOUT by the shell script to be displayed on the screen in real-time, is there some way I could do it?

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >