csh

regex - to check if input is number in csh(unix)

喜欢而已 提交于 2019-12-13 08:22:09
问题 Please help. How to make regex work in an if condition, to check user input(in 2nd parameter) must be not equal to any number? set regex="^[0-9]+$" if ($#argv == 2 && $2 != $regex) then # do this 回答1: grep-based solution that only works for non-negative integers . #!/bin/csh # Note this requires 2 command line arguments, and checks the second one # cshell arguments are 0-indexed. if ($#argv == 2) then # Note the different grep regexp syntax, and you must use single quotes set test = `echo $2

How to pass the Python variable to c shell script

余生颓废 提交于 2019-12-13 02:58:39
问题 I am using Centos 7.0 and PyDEv in Eclipse. I am trying to pass the variable in Python into c shell script. But I am getting error: This is my Python script named raw2waveconvert.py num = 10 print(num) import subprocess subprocess.call(["csh", "./test1.csh"]) Output/Error when I run the Python script: 10 num: Undefined variable. The file test1.csh contains: #!/bin/csh set nvar=`/home/nishant/workspace/codec_implement/src/NTTool/raw2waveconvert.py $num` echo $nvar 回答1: Okey, so apparently it's

python 2.6 subprocess enter psql password C shell

家住魔仙堡 提交于 2019-12-12 05:49:11
问题 I am not able to install any additional modules on an AIX server I am scripting on. It has Python 2.6.2 installed and basically I am trying to run the below command psql -c "select * from cms_agprm;" -o u350932.txt -d tctmsv80 -U tctmsv80 Now I have done some goggling and found a few different recommendation on how to do this. None with much success. I'm also a little paranoid because I am dealing with processes and want to make sure that i get things right in this script otherwise things

grep: broken pipe error python 2.2

ⅰ亾dé卋堺 提交于 2019-12-12 04:04:50
问题 I'm taking in a bunch of scripts, and creating a wrapper for them in python. I didn't create the scripts that were given to me. Currently I'm working with python 2.2, and the shell I'm using is a csh shell. When I run the script in the following manner: >> setenv some_var '/some/path/' >> <some more setenv> >> ./script -flag >& log.txt < /dev/null & It run's perfectly fine. The issue arises when I use a bash wrapper to call my python wrapper. My bash script (analysis.sh) is as follows: #!/bin

wait for two PID in c-shell

帅比萌擦擦* 提交于 2019-12-12 02:23:18
问题 Following works for me: >sleep 20 & [1] 30414 >sleep 30 & [2] 30415 >wait $30414 $30415 This works all right until I want to write this into tmp.csh In my tem.csh file sleep 20 & set pid1=$! sleep 30 & set pid2=$! When it comes to "wait" wait $pid1 $pid2 => too many arguments wait $pid1 => too many arguments wait \$$pid1 => too many arguments wait $($pid1) => Illegal variable name How shall I write it? And this question is for a solution of How can I wait until specified "xterm" finished? 回答1

Repeat printf arguments

萝らか妹 提交于 2019-12-12 00:34:53
问题 I've found some related posts, but nothing seems to work. I want to repeat the same argument $i for the instances 03-12. I'm really trying to use some nco operators - but the printf statement is hanging me up. #!/bin/csh set i = 1 while ($i < 2) `printf O3_BDBP_1979ghg.cam.h0.00{03,04,05,06,07,08,09,10,11,12}-%02d.nc $i` @ i = $i + 1 end The output is - so it gets it for 03 but not the rest. printf: O3_BDBP_1979ghg.cam.h0.0004-%02d.nc: expected a numeric value I've also tried this statement

Linux - Is it possible to store console output in a variable but with the same format as its present in console?

和自甴很熟 提交于 2019-12-11 20:46:10
问题 Here is my scenario: well i use csh 1) $ ls -l /corefiles/ | grep "root" -rw-r----- 1 root root 0 Sep 22 2014 core.3.4. -rwxr-x--- 1 root root 92 Sep 22 2014 ss.sh 2) $ set textInfo=`ls -l /corefiles/ | grep "root"` $ echo $textInfo -rw-r----- 1 root root 0 Sep 22 2014 core.3.4. -rwxr-x--- 1 root root 92 Sep 22 2014 ss.sh But I need echo $textInfo to give output like 1). How can I achieve this? I do not want to redirect the content into a file. I need to store console output in a variable but

Progress bar while Unix find command is executing

試著忘記壹切 提交于 2019-12-11 16:12:47
问题 I have a simple Unix shell script which is executing a time-consuming find command. Till it executes, my script appears non-responsive. However it's actually running in reality. How can I add a progress bar or print dots till the find command is executing? I want to print some dots or hash till the function doSomething is executing. function doSomething() { # Time-consuming 'for' loop below for var in `find XXXXXX` do # Some more processing done; } # Call the function doSomething. Need the

How to find from within a csh script whether a certain command is available?

孤者浪人 提交于 2019-12-11 14:19:53
问题 In a csh script, I need to perform something only if a certain command is available. I wanted to do something like if( _WHAT_TO_PUT_HERE_ ) then # enter only if command "cmd" is in the path cmd ... endif how to do that in csh or tcsh? 回答1: I guess using the where command will solve your issue Check this: ~/animesh >where grep /bin/grep /tools/cfr/bin/grep ~/animesh >where egrep /bin/egrep /tools/cfr/bin/egrep ~/animesh >where xgrep ~/animesh > so lets say you are trying to find a command

Setting an environment variable in csh

无人久伴 提交于 2019-12-11 06:39:45
问题 I have the following line at the first line in my script file: #!/bin/sh So I'm using csh.(?) I wanto assign the output of the following to an environment variable: echo $MYUSR | awk '{print substr($0,4)}' I try: set $MYVAR = echo $MYUSR | awk '{print substr($0,4)}' But it doesn't work, How can I do it? I want to do it in a sh file. 回答1: Your script should look like #!/bin/csh set MYVAR = `echo $MYUSR | awk '{print substr($0,4)}'` echo $MYVAR I don't have a way to test this right now, let me