unix

unix code inside perl

This is the code: #!/usr/bin/perl -w $dir=”/vol.nas/rpas_qc/mohima/Test/translations”; $dir1=”/vol.nas/rpas_qc/mohima/Test/dest”; `find $dir -type f -exec rsync -a {} $dir1`; This line: find $dir -type f -exec rsync -a {} $dir1 works fine in Unix but I am getting an error in perl: Can’t find string terminator “`” anywhere before EOF at test1.pl line 4 I am trying to copy all files in…
Read more

Writing string to pipe

I am trying to send a string to a pipe in unix. When I go through a line-by-line debugging process, the call mkfifo() creates the file in the same directory as the source code. However, when I reach the open() call, the debugger is no longer able to proceed. I’m not sure why it is unable to access the pipe…
Read more

Shell script : Year value is not returned

I am trying to get the year of the previous month. The below code is returning blank year value (i.,e no year value is printed) findPrvYear(){ ( set `date +%m” “%Y` CURMTHY=$1 CURYRY=$2 if [ $CURMTHY -eq 01 ] then PRVMTHY=12 PRVYRY=$(expr $CURYRY – 1) else PRVMTHY=$(expr $CURMTHY – 1) PRVYRY=”$CURYRY” fi return “$PRVYRY” ) } thisMonthY=$(date +%m) thisYearY=$(date +%y)…
Read more

grep pattern for getting words having alternate consonants and vowels

I have a text file file1.txt containing the following words abcdefghis abacadafag cdefghijka bedefegehj cidifigihi Question: How will I get the words with alternating consonants and vowels using grep pattern? My expected output is like this: abacadafag cidifigihi So far I have this code but it only displays words with alternating consonant and vowel on the first 2 characters. cat…
Read more

Customer display is buffering text and I need to "cat" the device to see it

I have a Posiflex customer display connected through a USB port in /dev/ttyACM0. I have used the same PC hardware, operating system and customer display in the past. However, the new customer displays I am testing now are buffering the text when I send text using the echo command. I send the text to the screen with a echo command:…
Read more

Using cat, head, tail, and tr with pipelines

Trying to do this little exercise. It’s not for homework or anything, but I want to make sure I understand it. Create 2 files. file1 will have 4 lines of text. file2 will have 6 lines of text. Create a pipeline that will print the last 2 lines of file1 and the first 3 lines of file2. Transliterate all lowercase…
Read more

Assembler Decompilation

I have a complicated assembler hw problem, the problem I am facing is essentially de-compiling assembler code. The goal being to figure out the password (with some encryption being done) I’ve spent some time turning the code into what i believe the pseudocode should be, i was wondering if some people far more experienced then I could maybe help point…
Read more

Fork bombs in unix

I was trying to understand fork bombs and came across this example – :(){ :|:& };: Here is the wiki page where this example is mentioned-Fork Bombs I am not able to figure out the use of | and & in this shell. Also I read somewhere that fork bombs can be used to manipulate scheduling in a multi-user environment….
Read more

Forked process writing to closed file descriptor stderr

I’ve come across a scenario I’d like help understanding. Example code is below. fclose(stdin); fclose(stdout); fclose(stderr); int sockets[2]; assert(socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) == 0); int socketA = sockets[0]; int socketB = sockets[1]; assert(socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) == 0); int socketC = sockets[0]; int socketD = sockets[1]; assert(socketA == 0); assert(socketB == 1); assert(socketC == 2); assert(socketD == 3); unblock_socket(socketA); unblock_socket(socketB);…
Read more