Im pulling an html document from a windows machine onto my linux box and the issue is the directory structure is not maintained between the two. This is how it looks in linux Im thinking of using a bash script that will change the “” into a “/” essentially making a folder. Im guessing …
Tag: bash
Python + pexpect – How to establish a ssh connection?
I’ve been trying to establish an ssh connection via Python + pexpect, but I can’t send the lines that I want. I think it’s certainly a syntax problem, but I don’t know where it is occurring. The problem is that the password ‘xxyyzz’ never appears on the terminal, so I think…
Shell Script ssh $SERVER >> EOF
I have a handy script here that can return accounts that will expire in 7 Days or have expired. I wanted to allow this to run on multiple hosts with out putting the script on each individual host, I added the for loop and the ssh $SERVER >> EOF part but it will just run the commands off they system
Linux C++ Detect user shell (csh,bash,etc)
I have a C++ application that needs to make shell specific commands using system calls. Is there a way to detect which shell the user is running? (Csh/Bash/etc). Thanks Elaborate I’m trying to work with some code that forks off via system a rsh call that has a sequence of commands that are using setenv …
Bash oneliner to rename filenames
I often would like to easily rename a bunch of files. I always have to struggle with find, grep, xargs and sed to simply to the job. I would like to understand how I can do a better job using PCRE Here my files: I would rename the dot files properly as I can do with this oneliner: However I
process a file remotely using ssh
I have this report.tex file which I convert to pdf as follows: These commands are placed in a file called linux_build This works great. However, this works on my Linux machine and most of my work I do on my Mac I checked out MacTex which is enormous (> 4GB) so I decided to process the latex file remotely (…
How to check a disk for partitions for use in a script in Linux?
I’m scripting something in Bash for Linux systems. How would I check a disk for partitions in a robust manner? I could use grep, awk, or sed to parse the output from fdisk, sfdisk, etc., but this doesn’t seem to be an exact science. I could also check if there are partitions in /dev, but it is als…
How to convert multiline file into a string in bash with newline character?
How can I convert a file with multiple lines to a string with n characters in bash? For example – I have a certificate that I need to configure in my configuration JSON file so instead of having I will have Answer One way using awk:
bash command not found when setting a variable
I am writing a shell script where I am setting few variables, whose value is the output of commands. The errors I get are: now, I did read other similar questions and based on it, I tried various things: spliting command into two calls tried using backticks tried using $() But in every case the command output…
sed – Piping a string before the last line in a file
I have a command that prints a single line. I want to add/pipe this line to a file, just above its last line. I just find an empty line in the correct place, above the last line. I notice that when I add any string as ‘$i foo’, the “foo” gets printed in the correct place, but I want th…