Programming :: Pass Carriage Return To Command Through Script
Feb 18, 2011
How can I pass carriage return to a command in the shell script. I am writing a shell script whcih generates ssh key pair. It ask for input from user three times. I want to pass carriage return (i.e., press Enter button) to this command.
How can I pass carriage return to a command. I am writing a shell script whcih generates ssh key pair. It ask for input from user three times. I want to pass carriage return (ie. press Enter button) to this command. Is tehre any way
I trying to write a UART(interfacing of serial devices) to linux machine but after I execute the following code to receive data I need to enter key (carriage return).... but I don't want to remove carriage return/enter key
I am testing the serial ports on a Single Board Computer(SBC) running Linux kernel 2.6.29. I usually do this by connecting the serial port to another PC serial port, then doing "cat /dev/ttyS0" on PC and "echo hello > /dev/ttyS0" on the SBC. However in the current system, "echo hello > /dev/ttyS0" command does not return at all! Also no characters appear on the destination port. I am running the echo command as root. The system boot messages show that the serial port in indeed /dev/ttyS0.
I'm creating a usb device driver that needs to be able to read from two different endpoints. I couldn't see any way of having two read functions in the driver, so I got round this by reading from one of the endpoints with read, and the other with ioctl.However this hasn't worked, the ioctl call from c returns -1. I added a printk command in the driver in the ioctl function, however looking at kern.log I can see that this function is never being called. Does anyone have any ideas as to what the problem called be, or a better method of being able to read from two different endpoints?
I'm trying to create a program that would locate the oldest file of a certain type on a server. Here's the commands:
OLDEST_PATH=`find -L / -depth -maxdepth 6 -mindepth 6 -type d | sort -f | head -1` OLDEST_FILE=`find -L $OLDEST_PATH | grep .mp3 | sort -f | head -1` ls -al $OLDEST_FILE
I'm writing this all in expect but I'm having problems. The main problem I have is whenever I try to run the first command, I can't seem to isolate the result of the OLDEST_PATH so that the 2nd command will work. There always seems to be a newline in the variable and the result is only "find -L" command running and it bypasses the variable. If I can just figure out how to get the 1st and 2nd command to work, then I can figure out the 3rd. Here's some code:
I know there is a better way to write this. I've tried multiple ways and this just happens to be the last way I've tried it. If you try running this, you'll notice that there is still carriage returns after the result of OLDEST_PATH and it prevents the 2nd "find" command from working properly.
1st variable CDR_2010-07-21(passed by var1) is the file name inside which i am trying to search string 9892614477(passed by var2). i have tried following script
I'm modifying a working udev rule which runs a script that mounts a USB HDD and synchronises files to it.The USB HDDs have been troublesome, losing many files and even losing file systems a couple of timesTo investigate,I want to log the USB HDD product name and serial number so would like to pass ATTRS{product} and ATTRS{serial} values to the script.This may not be possible; I cannot see anything about how to do it in either the udev man page nor Daniel Drake's "Writing udev rules" Version 0.74 but it seems such an obvious thing to want to do, I'm wondering if I've overlooked something.
I want to pass ip address,port address and some parameters from command line using python script.The ip address and port address for establishing socket connection and remaining parameters to execute different connection.
when I am running the script below,it performs on whatever logfile u type ,i.e, ./scriptname logfilename.But how do I convert it into a function and then call it from another script.I mean how do I prompt the user to enter a logname and then capture the name in the function and when calling this function from another script how do I pass the parameter.
I have a backup schedule running a full backup everyday. I'm using webmin to manage these backup now. The problem is when the dump command sends a prompt asking if we want to rewrite the tape, Webmin does not display this prompt and we end up having to terminate the backup -> erase the tape(which takes a long time) and then run the backup again.I was wondering if there is a technique that could be used to pass "Yes" as a parameter to the dump command, much like in windows? or if there is a more efficient way of getting this done.
I need to get a return code for the command ldapmodify.I try this and didn't workrc=ldapmodify -a -v -c -p $PORT -h $SRV -D cn=$USR,cn=Users,dc=company,dc=com -w $PWD -f $LDIFFILENAMECOUNTecho "return code " $rc what exactly the way to get the return code of that ?
I have access to backup server via rsync protocol (only rsync, nothing else). Now, I want to fetch file from there (which is .tar.gz) and pass it directly to tar command, without saving the archive in local filesystem. To visualize, with ssh access I could:
ssh remote_host cat backup.file.tar.gz | tar xzf - And I will get uncompressed backup locally, without actually storing .tar.gz on local machine. Is it possible to achieve when using rsync?
Below is an example output of what I see when I run the 'ls' command on some directories in linux (this is from a tomcat/common/lib directory). However I'm not clear on why some of the filenames are appearing inside [square brackets]
But in this way the command console will keep hang. Now I want to write a script which calls u this command and return back to the command console. Here is what I wrote but it doesn't return back to the command console:
Code:
#!/bin/sh MSGBP_HOME="/opt/jboss/MSGBP" case "$1" in start)
I want to have a choice or more preferable pass shell as command line argument when I ssh to an linux account.i.e. If John logs in to account "zzz" on server "abc", by default definition of account "zzz" n server "abc" he get csh.But Sally desires that when she logs in to account "zzz" on server "abc", she needs the login shell to be ksh,and Rick wants bash when he logs in to account "zzz" on server "abc".What is the most non-intrusive / easiest way to achieve this? Each user can set their preference on ssh command line or create a simple alias by each shell, but not sure how to do this.
I have a strange problem with a simple program. I have a container class that holds a pointer. I did this so I could use another container class that does several pass by value calls. I didn't want to be copying the object over and over again, so decided to build this simple container that simply copied the pointer in the copy constructor.
However, the pass by value call seems to be failing in a strange way. When the pass-by-value function is called, the program jumps into the copy constructor just fine and performs the pointer assignment operation. The program will copy the pointer value 0x20 (for argument sake) to the "this->base" location. Within the copy constructor, this has the address 0x28. Then when it jumps into the function, instead of pass by value argument being at 0x28 (as expected), it is at 0x36. Then 0x36->base has the address 0x28. Thus the base is now pointing at what was the new pointer container. At this point the data is corrupted and random things happen.
It seems that there is some strange assignment and double nesting going on. I really do not understand what is going on.
Below is some code. I have stripped away all the other code trying to isolate the problem. I have added comments explaining what my debugger is telling me.
Code: using namespace std; class paramPnt // Need to determine how order is tracked { private: long order;