So what i am trying to do is write a script that takes in any number of scrambeled words and unscrambles them.
I have already addressed the issues of partial matches, exits silently if there are no matches, and finds words regardless of case that they were input. but while trying to get it so that letter counts matched, so a word with two 'ss' would not get results with anything more or less than two 'ss', but i ran into an issue where my loop is dropping my last egrep when i run my eval cmd...
I cant seem to figure out why the echo shows the right command but when it evaluates the command it loses the last part?
I also am working on the need for if a word is entered with nin alpha characters and to ignore it and out put a message, and error handling so that no bash errors are thrown.
My code with debugging run to show how its dropping the last command
Code:
1 #!/bin/bash
2 echo "This Script interprets each input entered and descrambles the letters to determine the words that match. :)"
3
4 #[[ -z "$1"]] && echo "You must input 1 or more scrambled words to be unscrambled." && exit 1
5
6 until [ -z "$1" ]; do #Continue to take in parameters until none left
7 word=$1
8 len=${#word}
9 cmd="egrep -i \"\<[$word]{$len}\>\" /usr/dict/words"
10
11
12
13 for x in $(seq 0 $((len-1))) ; do
14 while [ -n "$word" ]; do
15
16 ltr=${word:0:1}
17 nxt=${word//[^$ltr]/}
18 cnt=${#nxt}
19 re="$cmd"
20
21 if [ "${cnt}" -gt "1" ];
22 then cmd="$re |egrep -i \"((${ltr}.*){${cnt}})\"";
23 #cmd="$re |egrep -i \"((.*${ltr}){${cnt}})\""
24 else
25 cmd="$re|egrep -i \"(${ltr}.*)\"";
26 fi
27
28 #echo $cmd
29
30 word=${word//$ltr/}
31 len=${#word}
32 done #End of for loop
33 done #End of for loop
34
35 echo $cmd
36 eval "$cmd" #Evaluate Regular Expression
37 shift #Shift parameters by 1
38 done #End of Until loop
Ok, i fixed the last issue, i had eval evaluating the wrong string set. I still need some help with interpreting the non alpha's if someone can help.
Hello
I need assistance with a bash script that needs to tell me whether in the last "x" days (which is a variable) anyone connected to the xxxx IP (which is another variable).
Thank you! (1 Reply)
So I am new to unix, and actually anything outside drag and drop with the mouse (been learning for about a week so far) . I have been using the foreach command in tcsh because I am working on a group of files. Basically what I need is to insert part of the filename as the first line in the file.... (0 Replies)
Hi.
The below part of my bash script kicks out the following error message:
$ ./extract_eod_report_stats_new.sh 2010-04-23
./extract_eod_report_stats_new.sh: line 204: syntax error near unexpected token `('
./extract_eod_report_stats_new.sh: line 204: `TRANSACTIONS_RECEIVED_TOP=`grep... (6 Replies)
Hi, i want to rename a group of directories and files of my music, some items are like this:
- , for directories.
- , for files.
I want to do something like this:
, for directories.
, for files.
This is my code:
#!/bin/bash
for fname in *.mp3; do
echo item: $fname
mv... (2 Replies)
Hey guys,
I've registered here as I need urgent help. This is assignment for school and as you can see below I've completed the work. I'm simply stuck on one area.
:wall:
This script takes the first parameter (which is to be the new extension) and each parameter after that is a file... (1 Reply)
Writing a bash script for use with Geektool, pulls the battery info, and shuffles images around so that an Image geeklet can display the correct expression as the desktop background. (Eventually I intend to make it more intricate, based on more variables, and add more expressions)
I'm extremely... (1 Reply)
Hi,
I'm having some trouble with using "case...esac" in Bash.
I've googled it and am stuggling to understand the syntax and how to do certain things.
Firstly, I want to be able to choose a case based on a variable number
For example, I have in my code a place where a user can enter... (2 Replies)
Hi all, I am trying to run a cronjob to push my files to my git repo once a week and output a prompt to a logfile, my script works fine if I invoke it manually but my cronjob wont run for some reason, I have sourced the file, and restarted my Mac to no avail, right now I believe I have the cronjob... (8 Replies)
I'm new to utilities like socat and netcat and I'm not clear if they will do what I need.
I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes.
I'm using Cygwin bash on Windows 10.
My... (3 Replies)
In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ?
--- Post updated at 08:39 AM ---
in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
Discussion started by: i4ismail
3 Replies
LEARN ABOUT DEBIAN
smb
SMB(4) BSD Kernel Interfaces Manual SMB(4)NAME
smb -- SMB generic I/O device driver
SYNOPSIS
device smb
DESCRIPTION
The smb character device driver provides generic i/o to any smbus(4) instance. In order to control SMB devices, use /dev/smb? with the
ioctls described below. Any of these ioctl commands takes a pointer to struct smbcmd as its argument.
#include <sys/types.h>
struct smbcmd {
char cmd;
int count;
u_char slave;
union {
char byte;
short word;
char *byte_ptr;
short *word_ptr;
struct {
short sdata;
short *rdata;
} process;
} data;
};
The slave field is always used, and provides the address of the SMBus slave device to talk to. The slave address is specified in the seven
most significant bits (i.e. ``left-justified''). The least significant bit of the slave address must be zero.
Ioctl Description
SMB_QUICK_WRITE The QuickWrite command just issues the device address with write intent to the bus, without transferring any data.
SMB_QUICK_READ The QuickRead command just issues the device address with read intent to the bus, without transferring any data.
SMB_SENDB The SendByte command sends the byte provided in the cmd field to the device.
SMB_RECVB The ReceiveByte command reads a single byte from the device which will be returned in the cmd field.
SMB_WRITEB The WriteByte command first sends the byte from the cmd field to the device, followed by the byte given in data.byte.
SMB_WRITEW The WriteWord command first sends the byte from the cmd field to the device, followed by the word given in data.word.
Note that the SMBus byte-order is little-endian by definition.
SMB_READB The ReadByte command first sends the byte from the cmd field to the device, and then reads one byte of data from the
device. The returned data will be stored in the location pointed to by data.byte_ptr.
SMB_READW The ReadWord command first sends the byte from the cmd field to the device, and then reads one word of data from the
device. The returned data will be stored in the location pointed to by data.word_ptr.
SMB_PCALL The ProcedureCall command first sends the byte from the cmd field to the device, followed by the word provided in
data.process.sdata. It then reads one word of data from the device, and returns it in the location pointed to by
data.process.rdata.
SMB_BWRITE The BlockWrite command first sends the byte from the cmd field to the device, followed by count bytes of data that are
taken from the buffer pointed to by data.byte_ptr. The SMBus specification mandates that no more than 32 bytes of data
can be transferred in a single block read or write command. This value is available in the constant SMB_MAXBLOCKSIZE.
SMB_BREAD The BlockRead command first sends the byte from the cmd field to the device, and then reads count bytes of data that from
the device. These data will be returned in the buffer pointed to by data.byte_ptr.
The read(2) and write(2) system calls are not implemented by this driver.
ERRORS
The ioctl(2) commands can cause the following driver-specific errors:
[ENXIO] Device did not respond to selection.
[EBUSY] Device still in use.
[ENODEV] Operation not supported by device (not supposed to happen).
[EINVAL] General argument error.
[EWOULDBLOCK] SMBus transaction timed out.
SEE ALSO ioctl(2), smbus(4)HISTORY
The smb manual page first appeared in FreeBSD 3.0.
AUTHORS
This manual page was written by Nicolas Souchu.
BSD February 6, 2009 BSD