csh

How to use parallel execution in a shell script?

最后都变了- 提交于 2019-11-30 16:30:29
问题 I have a C shell script that does something like this: #!/bin/csh gcc example.c -o ex gcc combine.c -o combine ex file1 r1 <-- 1 ex file2 r2 <-- 2 ex file3 r3 <-- 3 #... many more like the above combine r1 r2 r3 final \rm r1 r2 r3 Is there some way I can make lines 1 , 2 and 3 run in parallel instead of one after the another? 回答1: Convert this into a Makefile with proper dependencies. Then you can use make -j to have Make run everything possible in parallel. Note that all the indents in a

How can I view only the first n lines of the file?

巧了我就是萌 提交于 2019-11-30 09:00:54
问题 I tried head +10 and it didn't work. 回答1: Did you try the manpage for head? head -n 10 filename 回答2: Head is a fine tool, but you might also try: sed 10q path For code golf fanatics, sed is always better than head :) 来源: https://stackoverflow.com/questions/1411070/how-can-i-view-only-the-first-n-lines-of-the-file

How do you use newgrp in a script then stay in that group when the script exits

穿精又带淫゛_ 提交于 2019-11-30 03:12:19
问题 I am running a script on a solaris Box. specifically SunOS 5.7. I am not root. I am trying to execute a script similar to the following: newgrp thegroup << FOO source .login_stuff echo "hello world" FOO The Script runs. The problem is it returns back to the calling process which puts me in the old group with the source .login_stuff not being sourced. I understand this behavior. What I am looking for is a way to stay in the sub shell. Now I know I could put an xterm& (see below) in the script

Make python enter password when running a csh script

微笑、不失礼 提交于 2019-11-29 15:33:35
问题 I'm writing a python script that executes a csh script in Solaris 10. The csh script prompts the user for the root password (which I know) but I'm not sure how to make the python script answer the prompt with the password. Is this possible? Here is what I'm using to execute the csh script: import commands commands.getoutput('server stop') 回答1: Have a look at the pexpect module. It is designed to deal with interactive programs, which seems to be your case. Oh, and remember that hard-encoding

Not able to set LD_LIBRARY_PATH for Java process

守給你的承諾、 提交于 2019-11-29 07:33:30
I am trying to call my linux executable from shell script. Before calling this executable, I want to set LD_LIBRARY_PATH with specific values. My shell script is as below: Parent.sh (contains 2 lines) - source set_env.sh - executable.so Set_env.sh - setenv LD_LIBRARY_PATH /proj/something On manually executing Parent.sh scipt from linux console, the executable.so is called with LD_LIBRARY_PATH set correctly. But after integrating it wiht java code as: String[] commandArray ={"Parent.sh"}; Runtime runtime = Runtime.getRuntime(); Process javap = runtime.exec(commandArray); javap.waitFor(); LD

Move files that are 30 minutes old

有些话、适合烂在心里 提交于 2019-11-29 07:14:55
I work on a server system that does not allow me to store files more than 50 gigabytes. My application takes 20 minutes to generate a file. Is there any way whereby I can move all the files that are more than 30 minutes old from source to destination? I tried rsync : rsync -avP source/folder/ user@destiantionIp:dest/folder but this does not remove the files from my server and hence the storage limit fails. Secondly, if I use the mv command, the files that are still getting generated also move to the destination folder and the program fails. You can use find along with -exec for this:- Replace

Csh adding strings to an array, whitespace troubles

孤人 提交于 2019-11-29 07:14:52
I’m having trouble doing something basic with csh. I have a string: set newCmd = "$expansionCmd –option1 –option2 …" And I’m creating an array of these strings, which I later want to execute: set expansionCmdList = ($expansionCmdList[*] "$newCmd") #I also tried without quotes, e.g. just $newCmd Finally I try to iterate over and execute these commands: foreach exCmd ($expansionCmdList) `exCmd` #execute it in the shell end However the problem is that the array entries are not the full string, but every part of the string separated by whitespace, i.e. the first entry is just “$expansionCmd”, the

How can I echo commands in a tcsh script?

最后都变了- 提交于 2019-11-29 03:14:41
Yes. I know I shouldn't be using it for scripting. Yes. It is rubbish. I am indeed a fool. Nevertheless. I'd like to see the commands the script is executing, for debugging purposes. I think you get this effect with set -x or set -v in bash scripts. So e.g., if the script were #!/bin/tcsh echo "Hello" then when it ran, I'd see echo "Hello" Hello Put: set echo and/or set verbose at the top of your script. That will print out everything that happens in your script and are equivalent to the bash set -x and set -v commands. Lets say your script name is tcsh_file Lets assume this file includes

How would you include newline characters in a C-shell echo command?

冷暖自知 提交于 2019-11-28 09:06:49
问题 This sounds ridiculously easy, and it is with other shells. But I can't seem to figure out how to get echo to display newlines. For example - cat myFile shows the file as it actually exists, which is what I want - this is my file whereas my script, which contains the following - #!/bin/csh set var = `cat myFile` echo "$var" removes all the newlines, which is not what I want - this is my file Thanks in advance. 回答1: The problem isn't with the echo command, it's with csh's handling of backticks

how to source a csh script in bash to set the environment [closed]

心已入冬 提交于 2019-11-28 06:28:31
We have Oracle running on Solaris, and the shell is by default csh. So the login script sets the oracle_home, oracle_sid in csh also. But I don't like csh and want to use bash to do my work. So how to source the csh login script in bash? e.g, the following is what in the .cshrc file. And when use bash, I'd like use these variables. One way is to copy the variables again and use bash command, such as export ORACLE_SID=TEST. But doing so will require us to maintain two copies of the files. And when we change the database name, or upgrade the database, I need to maintain the bash login file