Sponsored Content
Top Forums UNIX for Beginners Questions & Answers C shell concatenate string doesn't work Post 303042760 by MadeInGermany on Monday 6th of January 2020 06:27:57 AM
Old 01-06-2020
The following does not work as intended:
Code:
            set r=$r | tr "\n" " "
            set r=$r | tr "\r" " "

                set lwp=$lwp | tr "\n" " "
                set lwp=$lwp | tr "\r" " "

Perhaps the input is DOS format, and you want to convert \r and \n to space; then the following might work better
Code:
            set r=`echo "$r" | tr "\r\n" "  "`

                set lwp=`echo "$lwp" | tr "\r\n" "  "`

In tr the string1 can ccontain more than one character; then string2 should have more than one character (here: two spaces) to allow a one-to-one mapping (otherwise different tr versions produce different results).

Last edited by MadeInGermany; 01-06-2020 at 07:53 AM.. Reason: removed outer quotes - csh has a parser error with "`" "`"
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep doesn't work within shell script?

I am trying to run the following code from a script file but it complains that syntax of (both instances of) grep is wrong. When I copy and paste it to the terminal, it is OK. Any idea what the problem might be? set i = `grep -c #define flags.h` while ($i>20) @ i-- my func (`cat... (4 Replies)
Discussion started by: barisgultekin
4 Replies

2. Shell Programming and Scripting

How to concatenate two strings or several strings into one string in B-shell?

like connect "summer" and "winter" to "summerwinter"? Can anybody help me? thanks a lot. (2 Replies)
Discussion started by: fontana
2 Replies

3. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

4. Shell Programming and Scripting

Perl cmds doesn't work in Bash shell . Plz help

Hi everyone, I have a Linux OS in my PC (older version 9). Its default shell is bash. Whenever I try to run some Perl program it throws error ! eg, if I run this simple PERL program , #!/usr/bin/perl printf "\lHello \n"; $var=3 ; printf $var; @list=(1,2,3); printf "@list";... (6 Replies)
Discussion started by: adc22
6 Replies

5. Shell Programming and Scripting

shell script, echo doesn't work

#!/bin/sh something(){ echo "Inside something" echo $1 $2 } val=$(something "Hello " "world") Output expected: Inside somethingHello world But it's not echoing. (4 Replies)
Discussion started by: cola
4 Replies

6. Shell Programming and Scripting

Replace string with sed doesn't work

Hello, Unfortunately I don't found any working solution for my problem :/ I have pass file for dovecot authorizing in this format: user@domain.tld:{SSHA}Ykx2KVG/a2FKzjnctFFC2qFnrk9nvRmW:5000:5000:::: . . ...Now, I want to write some sh script for password changing for grep'ed user, in... (5 Replies)
Discussion started by: vincenty
5 Replies

7. UNIX for Dummies Questions & Answers

find command in shell script doesn't work

Hello all, Something strange going on with a shell script I'm writing. It's trying to write a list of files that it finds in a given directory to another file. But I also have a skip list so matching files that are in that skip list should be, well uhm, skipped :) Here's the code of my... (2 Replies)
Discussion started by: StijnV
2 Replies

8. Shell Programming and Scripting

Switching user inside a shell script doesn't seem to work

Linux version : Oracle Linux 6.4 Shell : Bash The following script will be run as root. During the execution, it should switch to oracle user and execute few commands. After googling and searching within unix.com , I came up with the following syntax ## Enclosing all commands in double... (7 Replies)
Discussion started by: John K
7 Replies

9. HP-UX

Su to another user from root doesn't work within shell script

Hello I have a shell script that is run as root. Script rins ok until the point where it have to switch to user "mqm" to run other commands. It just hangs at the point of this line in the script su - mqm -c "dspmq" I ran the same commands at the terminal and they run fine. Any thoughts. (6 Replies)
Discussion started by: mo12
6 Replies

10. UNIX for Beginners Questions & Answers

Concatenate a string and number and compare that with another string in awk script

I have below code inside my awk script if ( $0 ~ /SVC IN:/ ) { svc_in=substr( $0,23 , 3); if (msg_start == 1 && msg_end == 0) { msg_arr=$0; } } else if ( $0 ~ /^SVC OUT:/ ) { svc_out=substr( $0, 9, 3); if (msg_start == 1 && msg_end == 0) ... (6 Replies)
Discussion started by: bhagya123
6 Replies
RUMP_LWPROC(3)						   BSD Library Functions Manual 					    RUMP_LWPROC(3)

NAME
rump_lwproc -- rump process/lwp management LIBRARY
rump kernel (librump, -lrump) SYNOPSIS
#include <rump/rump.h> int rump_pub_lwproc_rfork(int flags); int rump_pub_lwproc_newlwp(pid_t pid); void rump_pub_lwproc_switch(struct lwp *l); void rump_pub_lwproc_releaselwp(); struct lwp * rump_pub_lwproc_curlwp(); DESCRIPTION
In a normal operating system model a process is a resource container and a thread (lwp) is the execution context. Every lwp is associated with exactly one process, and a process is associated with one or more lwps. The current lwp (curlwp) indicates the current process and determines which resources, such as UID/GID, current working directory, and file descriptor table, are currently used. These basic princi- ples apply to rump kernels as well, but since rump uses the host's thread and process context directly, the rules for how thread context is determined are different. In the rump model, each host thread (pthread) is either bound to a rump kernel lwp or accesses the rump kernel with an implicit thread con- text associated with pid 1. An implicit thread context is created every time the rump kernel is entered and disbanded upon exit. While con- venient for occasional calls, creating an implicit thread uses a shared resource which can become highly contended in a multithreaded situa- tion. It is therefore recommended that dedicated threads are created. The association between host threads and the rump kernel curlwp is left to the caller. It is possible to create a dedicated host thread for every rump kernel lwp or multiplex them on top of a single host thread. After rump lwps have been created, switching curlwp is very cheap -- faster than a thread context switch on the host. In case multiple lwps/processes are created, it is the caller's responsibility to keep track of them and release them when they are no longer necessary. Like other rump kernel resources, procs/lwps will be released when the process hosting the rump kernel exits. rump_pub_lwproc_rfork() Create a process, one lwp inside it and set curlwp to the new lwp. The flags parameter controls how file descriptors are inherited from the parent. By default (flags=0) file descriptors are shared. Other options are: RUMP_RFFDG Copy file descriptors from parent. This is what fork(2) does. RUMP_RFCFDG File descriptors neither copied nor shared, i.e. new process does not have access to the parent's file descriptors. This routine returns 0 for success or an errno indicating the reason for failure. The new process id can be retrieved in the normal fashion by calling rump_sys_getpid(). rump_pub_lwproc_newlwp(pid) Create a new lwp attached to the process specified by pid. Sets curlwp to the new lwp. This routine returns 0 for success or an errno indicating the reason for failure. rump_pub_lwproc_switch(l) Sets curlwp to l. In case the new thread is associated with a different process than the current one, the process context is also switched. The special value NULL sets curlwp to implicit context. Switching to an already running lwp, i.e. attempting to use the same curlwp in two host threads simultaneously causes a fatal error. rump_pub_lwproc_releaselwp() Release curlwp and set curlwp to context. In case curlwp was the last thread inside the current process, the process container is also released. Calling this routine without a dedicated curlwp is a fatal error. rump_pub_lwproc_curlwp() Returns curlwp or NULL if the current context is an implicit context. SEE ALSO
getpid(2), rump(3) HISTORY
rump_lwproc first appeared in NetBSD 6.0. BSD
January 2, 2011 BSD
All times are GMT -4. The time now is 08:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy