csh

Do we have short circuit logical operators in C shell script?

血红的双手。 提交于 2021-02-19 07:23:12
问题 I thought C shell script will behave like C and use short circuit evaluation for logical operators. if ((! -e $cache ) || ("`find $monitor -newer $cache`" != "")) then ... endif But in the if statement, even if the first condition is true, the second is checked giving me errors. Do we have a short circuit logical OR in C shell script? 回答1: Usually, && and || are short-circut. Consider something like this: $ false && echo foo $ true || echo foo In both cases, foo won't be put out. But, AFAIK

change working directory from csh script

霸气de小男生 提交于 2021-01-28 21:43:40
问题 I want to lookup some data of running processes, actually I'm searching for the scratch directory to a corresponding job-ID. I managed to do that manually by the following commands (assuming the job-ID is 12345): find ~ -name '12345.out' This finds the output file according to the job: /home/username/somefolder/12345.out The scratch directory is written to a file named .scrdir in that folder, so cd | cat /home/username/somefolder/.scrdir brings me where I want. I now want to combine that to a

How do I get `__FILE__` when sourcing a csh script

a 夏天 提交于 2021-01-26 17:59:30
问题 I have a script that is used to set some env vars in the calling csh shell. Some of those variables depend on the location of the script. If the file is a proper csh script, I can use $0 to access __FILE__ but if I run the script using source, it just tells me csh or tcsh. Since I'm using this to set vars in the parent shell, I have to use source. What to do? 回答1: If you access $_ on the first line of the file, it will contain the name of the file if it's sourced. If it's run directly then $0

Repeat printf arguments with command line operators

烈酒焚心 提交于 2020-03-26 07:34:28
问题 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. I'm trying to use an netcdf operator on it - where these outputs of the printf are the input files to the command. While this works now with the printf statements, it's not piping into the netcdf command. Which goes as: ncea -v T,U inputfiles outputfile #!/bin/csh set i = 1 while ($i < 2) ncea -v T,U foreach j ( {3,4,6,7,8,9,10,11,12} )

How to test the return of a command in U-Boot CLI

只谈情不闲聊 提交于 2020-03-05 05:09:25
问题 I would like to use the return of the command 'gpio input' in an if statement in U-Boot but it doesn't seem to work. So I've tried something like : if test {gpio status 50} -eq 1; then echo 1; else echo 0; fi; But it always return 1 whether the GPIO is high or low. I also tried to store the result of the gpio status command into a variable by using the setenv command but it doesn't work either. PS: I've modified the gpio.c file in the U-boot source code so the command returns just '0' or '1'

csh alias with variable number of arguments

倾然丶 夕夏残阳落幕 提交于 2020-03-04 16:45:07
问题 I would like to create a csh alias that performs one operation if invoked without arguments and a second operation if invoked with a single argument. Does anyone know how to do this? (Attempting to refer to an argument that wasn't passed triggers an error). 回答1: I know this is a bit late but I just ran into needing something similar and hope it might still be relevant to somebody. You can set the arguments as an array and query based on the size of the array: alias testing 'set args_=(\!*);

Setting environments variables from a python script

二次信任 提交于 2020-01-23 17:30:09
问题 I am using c-shell and I am used to using setenv. I need to execute an equivalent command from within a python script. I tried using os.environ['JAVA_HOME'] = "/usr/local/java" which works from the python interpreter, but when my script is executed from the command line, the shell it ran in does reflect the newly set environment variable. Can anybody help, I am new to scripting, I hope I made my question clear. 回答1: If you're using subprocess.Popen, it should be enough to pass the env

Calculate 8 working days in past in Informix

橙三吉。 提交于 2020-01-17 02:59:26
问题 I'm trying to write a script in C shell for selecting data from Informix database 8 working days in past. So far I have sql code that calculate 8 days in past + Sunday and Saturday it looks like this: select * from ekzo where datzah = today- (case when weekday(today) = 1 then 12 when weekday(today) = 2 then 12 when weekday(today) = 3 then 12 when weekday(today) = 4 then 10 when weekday(today) = 5 then 10 when weekday(today) = 6 then 10 when weekday(today) = 0 then 11 end) I have created table

Calculate 8 working days in past in Informix

只谈情不闲聊 提交于 2020-01-17 02:59:04
问题 I'm trying to write a script in C shell for selecting data from Informix database 8 working days in past. So far I have sql code that calculate 8 days in past + Sunday and Saturday it looks like this: select * from ekzo where datzah = today- (case when weekday(today) = 1 then 12 when weekday(today) = 2 then 12 when weekday(today) = 3 then 12 when weekday(today) = 4 then 10 when weekday(today) = 5 then 10 when weekday(today) = 6 then 10 when weekday(today) = 0 then 11 end) I have created table

csh set: no match error wildcard

為{幸葍}努か 提交于 2020-01-07 03:22:44
问题 trying to look up files in directories with wildcard *, and put the names into an array the files have similar names (MATCHr1, MATCHr2 ... ) the problem arises when the file does not exist (which is a possibility) set command returns a "no match" error and terminates the loop if this happens how can i get it handle the error by jumping to the next iteration? set SUBIDS = (10003 10005 10006) foreach SUBID ($SUBIDS) foreach SEQR ( MATCH ENC NBACK SIMON FACE ) ls -l *${SEQR}*.nii.gz set Array =