csh

Redirect stderr to stdout in C shell

喜夏-厌秋 提交于 2019-11-26 15:29:54
问题 When I run the following command in csh , I got nothing, but it works in bash . Is there any equivalent in csh which can redirect the standard error to standard out? somecommand 2>&1 回答1: The csh shell has never been known for its extensive ability to manipulate file handles in the redirection process. You can redirect both standard output and error to a file with: xxx >& filename but that's not quite what you were after, redirecting standard error to the current standard output. However, if

How to determine the current shell I'm working on?

允我心安 提交于 2019-11-26 11:27:28
How can I determine the current shell I am working on? Would the output of the ps command alone be sufficient? How can this be done in different flavors of UNIX? DVK There are 3 approaches to finding the name of the current shell's executable: Please note that all 3 approaches can be fooled if the executable of the shell is /bin/sh but it's really a renamed bash , for example (which frequently happens). Thus your second question of whether ps output will do is answered with " not always ". echo $0 - will print the program name... which in the case of shell is the actual shell ps -ef | grep $$

Maximum length of command line argument that can be passed to SQL*Plus?

荒凉一梦 提交于 2019-11-26 08:59:57
问题 I am calling SQL*Plus from Linux C Shell: sqlplus username/password @file.sql var1 var2 var3 If I pass a string as var1 , how long can this string be? Is it governed by the OS? In this case: Linux version 2.6.9-100.ELsmp (mockbuild@x86-010.build.bos.redhat.com) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-11)) #1 SMP Tue Feb 1 12:17:32 EST 2011 Update: Empirical testing yielded the following results: A command line argument of 5200 characters gave the error, \"Word too long.\" 1300 characters

Extract one word after a specific word on the same line

徘徊边缘 提交于 2019-11-26 07:48:04
问题 How can I extract a word that comes after a specific word in Linux (csh)? More precisely, I have a file which has a single line which looks like this: [some useless data] --pe_cnt 100 --rd_cnt 1000 [some more data] I want to extract the number 100 which is after the --pe_cnt word. I cannot use sed as that works only if you want to extract an entire line. Maybe I can use awk? Also, I have multiple files that have different values instead of 100 so I need something that extracts the value but

How to keep from duplicating path variable in csh

人走茶凉 提交于 2019-11-26 07:37:46
问题 It is typical to have something like this in your cshrc file for setting the path: set path = ( . $otherpath $path ) but, the path gets duplicated when you source your cshrc file multiple times, how do you prevent the duplication? EDIT: This is one unclean way of doing it: set localpaths = ( . $otherpaths ) echo ${path} | egrep -i \"$localpaths\" >& /dev/null if ($status != 0) then set path = ( . $otherpaths $path ) endif 回答1: you can use the following Perl script to prune paths of duplicates

How to determine the current shell I'm working on?

社会主义新天地 提交于 2019-11-26 03:31:47
问题 How can I determine the current shell I am working on? Would the output of the ps command alone be sufficient? How can this be done in different flavors of UNIX? 回答1: There are 3 approaches to finding the name of the current shell's executable: Please note that all 3 approaches can be fooled if the executable of the shell is /bin/sh but it's really a renamed bash , for example (which frequently happens). Thus your second question of whether ps output will do is answered with " not always ".

Can a shell script set environment variables of the calling shell? [duplicate]

时光怂恿深爱的人放手 提交于 2019-11-26 01:22:06
问题 This question already has answers here : Can I export a variable to the environment from a bash script without sourcing it? (7 answers) Closed 8 months ago . I\'m trying to write a shell script that, when run, will set some environment variables that will stay set in the caller\'s shell. setenv FOO foo in csh/tcsh, or export FOO=foo in sh/bash only set it during the script\'s execution. I already know that source myscript will run the commands of the script rather than launching a new shell,

Getting ssh to execute a command in the background on target machine

六眼飞鱼酱① 提交于 2019-11-26 01:03:10
问题 This is a follow-on question to the How do you use ssh in a shell script? question. If I want to execute a command on the remote machine that runs in the background on that machine, how do I get the ssh command to return? When I try to just include the ampersand (&) at the end of the command it just hangs. The exact form of the command looks like this: ssh user@target \"cd /some/directory; program-to-execute &\" Any ideas? One thing to note is that logins to the the target machine always

Getting ssh to execute a command in the background on target machine

南楼画角 提交于 2019-11-25 23:14:49
This is a follow-on question to the How do you use ssh in a shell script? question. If I want to execute a command on the remote machine that runs in the background on that machine, how do I get the ssh command to return? When I try to just include the ampersand (&) at the end of the command it just hangs. The exact form of the command looks like this: ssh user@target "cd /some/directory; program-to-execute &" Any ideas? One thing to note is that logins to the the target machine always produce a text banner and I have SSH keys set up so no password is required. I had this problem in a program