shell

How to resume CUPS printer from command line

Hello I have printer in CUPS that due driver problems (hp 1010) form time to time goes into pause. I would like to write a shell script that will be once per hour resuming printer in cups. But I have no idea after googling for couple of minutes how to resume printer from shell command line. Regards Stan ...

Using sed to mass rename files

Objective Change these filenames: F00001-0708-RG-biasliuyda F00001-0708-CS-akgdlaul F00001-0708-VF-hioulgigl to these filenames: F0001-0708-RG-biasliuyda F0001-0708-CS-akgdlaul F0001-0708-VF-hioulgigl Shell Code To test: ls F00001-0708-*|sed 's/\(.\).\(.*\)/mv & \1\2/' To perform: ls F00001-0708-*|sed 's/\(.\).\(.*\)/mv & \...

Custom script in .screenrc

Hi. I made a script that spawns a remote shell or runs a local shell whether it's on the current machine or not: #!/bin/bash # By: benoror <[email protected]> # # spawns a remote shell or runs a local shell whether it's on the current machine or not # $1 = hostname if [ "$(hostname)" == "$1" ]; then bash else ssh "$1.local" fi...

Searching a CSV File Using Grep

Lets say I have a csv file like this: a,b1,12, a,b1,42, d,e1,12, r,12,33, I want to use grep to return only only the rows where the third column = 12. So it would return: a,b1,12, d,e1,12, but not: r,12,33, Any ideas for a regular expression that will allow me to do this? ...

Pass a string containing the * (asterisk) character as a command line argument in Windows Shell

I am looking for a way to pass a string containg the "*" character to an executable via the command line. command.exe 3*2 I want to pass the string 3*2. What Windows does instead is search the current directory for files matching the file mask "3*2", and passes any files it found to command.exe Putting "3*2" between double quotes d...

Easy shell solution to execute a command for each line of stdout

Hi, This should be an absurdly easy task: I want to take each line of the stdout of any old command, and use each to execute another command with it as an argument. For example: ls | grep foo | applycommand 'mv %s bar/' Where this would take everything matching "foo" and move it to the bar/ directory. (I feel a bit embarrassed askin...

How to embed a graphical interactive IronPython shell in an application?

I've tried the obvious path in my pet open source project RevitPythonShell (a plugin for the building modeling software Autodesk Revit Architecture 2010): code.interact() with the IronPython engine set up to use .NET streams for STDIN and STDOUT. These I then redirect to a TextBox control. It kinda works, but really is only an ugly hack....

what is more efficient: read in file from java or shell script?

I'm trying to figure out what is more efficient in terms of server load which is pretty big at the moment, additional overload wouldn't be a great idea. Here is what I need to do : I have a log file which changes, sometimes every second other times every few minutes or so which is not really relevant to this question. I'm trying to find...

While loop to test if a file exists in bash

Hello, I'm working on a shell script that does certain changes on a txt file only if it does exist, however this test loop doesn't work, I wonder why? Thank you! while [ ! -f /tmp/list.txt ] ; do sleep 2 done ...

(shell) How to remove strings from one file which can be found in another file?

Hello, file1.txt aaaa bbbb cccc dddd eeee file2.txt DDDD cccc aaaa result bbbb eeee If it could be case insensitive it would be even more great! Thank you! ...

Shell Script - Linux

Hey, I want to write a very simple script , which takes a process name , and return the tail of the last file name which contains the process name. I wrote something like that : #!/bin/sh tail $(ls -t *"$1"*| head -1) -f My question: Do I need the first line? Why isn't ls -t *"$1"*| head -1 | tail -f working? Is there a better wa...

What is the subprocess.Popen max length of the args parameter?

I am using Popen function from the subprocess module to execute a command line tool: subprocess.Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0) The tool I am using takes a list o...

Window shell script return codes

Is there a standard set of return code for Window shell scripts (*.bat files)? I'm looking for something analogous to Linux exit codes, where 0==success and non-zero==failure. I need a way to programmatically check if my shell script failed during execution. ...

Shell Script - save substring to variable

Hey, A really simple shell script question. I have a file with something like this: var "aaaaa" var "bbbbb" ... Now, how can I assign the string in quotes to a variable? This is what I have now (but I'm missing the assign part...): while read line do echo $line | cut -d" " -f3 done which prints what I want... how do I save it to...

Windows 7 Federated Search - How to make it send search requests to my .net assembly

I am trying to display search results in the windows 7 explorer thru the federated search feature, from a local .net assembly. (not from a web service) I have found various tutorials, but all of them are for web services. Earlier I thought that it was not possible but then, I came across the StickyNotes federated search connector. The c...

Shell script that asks user to continue with a y/n

I have a shell script that I want to ask the user if they want to continue. If they type 'n' and press enter the script will exit. If they press 'y' and enter it will continue to run. I have this at the top of my script but it continues regardless of what I type. What am I doing wrong ? goon= while [ -z $goon ] do echo -n 'Do yo...

How do I use cp to copy one directory to new name repeatedly and correctly?

I am writing a makefile. However except for the path expansion and restrictions on what I can do, this is basically a shell scripting question. As part of the make process, I want to copy a directory to the destination. My source directory and destination directory are variables, so I can't assume a lot about them. They may be fully qual...

How do i begin writing a windows shell extension?

I'm looking at writing a shell extension so when a file is clicked an action can be performed against it. (Like any other context menu :)) What is the minimum i need to insert a new Menu Item in the Context menu and perform an action against one or more files. A comparative example would be that i selected 10 files and Send to Zip. I...

script unable to find directories/files when running from qsub cluster script

I'm calling several unix commands and python on a python script from a qsub shell script, meant to run on a cluster. The trouble is that when the script executes, something seems to go awry in the shell, so that directories and files that exist are not found. For example, in the .out output files of qsub I see the following errors: cd...

Including date and time in Tex File

Hello, The latex file is giving the following error ! LaTeX Error: File `datetime.sty' not found. Here is the Latex Code : \usepackage{datetime} Please let me know, if I am missing something. I am using Debian 3.1 Linux Machine. Would appreciate any useful pointers or help. Thanks Kiran ...