shell

Can i get the absolute path of just moved file to somewhere in native file system from known folder?

I am recently working on a java desktop application which needs to track a path of file which has been recently moved to somewhere in native file system from the known source. For Example : - Let's suppose i have a file A.txt in %TEMP% folder (C:\Users\Admin\AppData\Local\Temp\A.txt). Now Operating system moves that file to, suppose my ...

bash "map" equivalent: run command on each file

I often have a command that processes one file, and I want to run it on every file in a directory. Is there any built-in way to do this? For example, say I have a program data which outputs an important number about a file: ./data foo 137 ./data bar 42 I want to run it on every file in the directory in some manner like this: map da...

Run Exchange Management Shell cmdlets from Visual Basic/C#/.NET app

Goal: Provide a web service using Visual Basic or C# or .NET that interacts with the Exchange Management Shell, sending it commands to run cmdlets, and return the results as XML. (Note that we could use any lanaguage to write the service, but since it is a Windows Box and we have Visual Studio 2008, it seemed like easiest solution would ...

Read a variable in bash with a default value

I need to read a value from the terminal in a bash script. I would like to be able to provide a default value that the user can change. # Please enter your name: Ricardo^ In this script the prompt is "Please enter your name: " the default value is "Ricardo" and the cursor would be after the default value. Is there a way to do this i...

busybox shell refuses to execute the particular line of script

Hi, I am using busybox shell to execute a script which the bash executes when i boot linux using the nfs. Please let me know the correct alternative for this line. cur_major=$((0x`stat -c %t $dev 2>/dev/null`)) The busybox throws in an error saying "0x" syntax error, which i understand is the problem with the syntax of this line. Th...

Shell script argument parsing

There are a number of questions about this sort of thing but lets imagine we are targeting a generic Linux system with both getopt and getopts installed (not that we'll use either, but they seem popular) How do I parse both long (--example | --example simple-option) and short argruments (-e | -esimple-example | -e simple-example) ...

problem with piping in my own implementation of shell

Hey guys, i am implementing my own shell. I want to involve piping. i searched here and i got a code. But it is not working.Can any one help me? this is my code #include <sys/types.h> #include <sys/wait.h> #include <sys/ipc.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <iostream> #include <cstdlib>...

balancing rsync in directories

i need to rsync a remote directory to a local server, balancing file in 4 destination directory (related to 4 disk mounts). tips? ...

Resetting NTFS dirty bit

Hi folks! I'd like to know whether it's possible to clear the NTFS dirty bit in bash script. Thanks, User114788 ...

Exclude specific filename from shell globbing

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. ...

How to pass parameters to a Linux Bash script?

I have a Linux bash script 'myshell'. I want it to read two dates as parameters, for example: myshell date1 date2. I am a Java programmer, but don't know how to write a script to get this done. The rest of the script is like this: sed "s/$date1/$date2/g" wlacd_stat.xml >tmp.xml mv tmp.xml wlacd_stat.xml ...

Help with simple linux shell implementation

I am implementing a simple version of a linux shell in c. I have succesfully written the parser, but I am having some trouble forking out the child process. However, I think the problem is due to arrays, pointers and such, because just started C with this project and am not still very knowledgable with them. I am getting a segmentation...

Show last command with up arrow on a linux c shell

I have implemented a simple linux shell in c. Now, I am adding some features and one I immediately thought about was to be able to show the last commands with the up arrow. Question 1: However, I have no idea how to accomplish this. Do you? Question 2: Any comment on how to store the "history" commands are also appreciated. I suppose s...

Python Fabric: How to handle arbitrary remote shell prompt for input?

This is related to this question here, but with a slight twist: instead of just passing 'yes' or 'no', I need Fabric to pass an arbitrary string to the remote shell. For instance, if the remote shell prompts for 'what is your name?' then I need to feed it 'first,last'. Clarification: I know I said arbitrary input, but I was really tryi...

Shell - Run additional command on failure

I have this script that I am currently running that works great for all instances but one: #!/bin/sh pdfopt test.pdf test.opt.pdf &>/dev/null pdf2swf test.opt.pdf test.swf [ "$?" -ne 0 ] && exit 2 More lines to execute follow the above code ... How would I go about changing this script to run "pdf2swf test.pdf test.swf" if "pdf2s...

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

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 out...

shell scripting: search/replace & check file exist

I have a perl script (or any executable) E which will take a file foo.xml and write a file foo.txt. I use a Beowulf cluster to run E for a large number of XML files, but I'd like to write a simple job server script in shell (bash) which doesn't overwrite existing txt files. I'm currently doing something like #!/bin/sh PATTERN="[A-Z]...

Bash script to pull out x number of starting comment lines into another file

I am looking for a one liner to pull out the first comment block in any file. The comment blocks look like this: /* * This is a * comment block */ I've been trying to play with sed, but just can't get it to work right. Help? ...

Pipe implementation

I am trying to implement a linux shell that supports piping. I have already done simple commands, commands running in background, redirections, but piping is still missing. I have already read about it and seen some snippets of code, but still haven't been able to sort out a working solution. What I have so far: int fd[2]; pipe(fd); ...

numeric cycles in shell

hello, what is the name and syntax of the construction ((..)) in example below? for ((i=1;i<10;i++)) do echo $i; done it has strange variable i where are other constructions for numeric cycling in shells? ...