I want to append lines after a match in a file.
##file name is ssl.conf
##match is this
<Directory "/var/www/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
after above line i need to append these lines
<Directory "/">
SSLRenegBufferSize 26215000
</Directory>
so final results should be like this
<Directory "/var/www/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
<Directory "/">
SSLRenegBufferSize 26215000
</Directory>
######Thank You in Advance
Hello, I have an embedded linux device. I can connect to the device and I can upload or download files. No problem with this. But, at first connection, I want to connect to "/" directory instead of "/root". In the device file system, there are files ssh_config and sshd_config under /etc/ssh directory. I think I have to do something with these files but I don't know what.
I don't exactly know what mean "/root" and "/" directories. I think that the real root directory is "/" directory which is empty but when I connect with filezilla, the "/root" directory is the default so I had to go back to / directory everytime.
hello all,
please help me with python ftplib. i was trying to copy files from my linux machine to a windows server using ftplib. everything was working good. but i'm only able to copy files from the same directory the script is. how do i copy files from a different directory? i always get "file not found error message". here's my code :
Code:
tester_name = str (socket.gethostname())
def upload(ftp, file):
ext = os.path.splitext(file)[1]
if ext in (".txt", ".htm", ".html"):
ftp.storlines("STOR " + file, open(file))
else:
ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
parse_source_path = ('/path/to/where/i/go/')
parse_source_file_list = os.listdir(parse_source_path)
ftp = ftplib.FTP("server_IP")
ftp.login("username", "pass")
folder_list = []
ftp.dir(folder_list.append)
if str(tester_name) not in str(folder_list) :
ftp.mkd("%s"%tester_name)
ftp.cwd("%s"%tester_name)
for files in parse_source_file_list :
print files
upload(ftp, files)
else :
print "later"
I copied the following from my linux console.
grep -lr "SMTP" *.ini
grep: *.ini: No such file or directory
I wanted to search recursively under current location in files with extenstion .ini
Actually there are files that contain "SMTP" under this directory. But I got the above error message.
What is wrong? I am using centos 6.
Thanks,
3rock
Hello,
I have a flat file where I expect to have 5 values delimited by 4 commas ",' :
agf,sdya,geg,fgd,gdfgr
but sometimes I have the following:
agf,sdya,geg,fgd
agf,sdya,geg
agf,sdya
agf
For those lines, I wanna append commas at the end of the lines in order to always have a total of 4 commas:
agf,sdya,geg,fgd,
agf,sdya,geg,,
agf,sdya,,,
agf,,,,
The following awk command already gives me the count number of "," for each line:
awk -F\, '{print NF-1}' "MyFile"
But I am not sure where to go from there.
Basically I want to do the following;
If CommaCount For CurrentLine != 4 Then Append(4 - "number of commas found')CommasToLine
Else CheckNextLine.
Thanks for your help !
I have a bash script executing on an AIX server to a windows share directory to update a windows text file. Most of the file is edited as expected but I have 3 issues that I am not sure how to resolve.
1. Windows text file contains a double backslash (\\) and the \\ is being written back as a single \ which corrupts the file.
2. I am not getting the last line of text in the file written back out.
3. Some lines of text are not written back out completely.
Here is a snippet of my bash script:
cp $Directory/Somefile $Directory/Somefile.$(date +'%Y%m%d')
cat /dev/null > ${HOME}/temp.out
while read -r inpLine; do
patternFound=n
echo ${inpLine} | grep -q 'SOMEPATTERN='
if [ $? = 0 ]; then
patternFound=y
echo "##${inpLine}" >> ${HOME}/temp.out
echo "SOMEPATTERN=newValue" >> ${HOME}/temp.out
fi
if [ ${patternFound} = "n" ]; then
echo ${inpLine} >> ${HOME}/temp.out
fi
done < $Directory/Somefile
mv ${HOME}/temp.out $Directory/Somefile
I have a directory w/ a file that I created using:
Code:
fd = open("file", O_CREAT);
The file turned out to be executable. When I did a 'ls -l' on the directory w'/ that file it has a "T" at the end of the permissions where the executable bit would be set for the "other" group.
Hello everyone,
Although it seems easy, I've been stuck with this problem for a moment now and I can't figure out a way to get it done.
My problem is the following:
I have a file where each line is a sequence of IP addresses, example :
Line 1: 10.0.01 10.0.0.2
Line 2 : 10.0.0.5 10.0.0.1 10.0.0.2
...
What I'd like to do, is to remove lines that are completely matched in other lines. In the previous example, "Line 1" would be deleted as it is contained in "Line 2".
So far, I've worked with python and set() objects to get the job done but I've got more than 100K lines and sets lookups are becoming time consuming as the program goes :/
Thanks for you help
Stupid question i know. I am trying to install some brother printer drivers and following the instructions it states that i must change to the directory where the file is stored by using the following command line "cd /home/(loginname)/downloads"
this comes back with unkown directory. When i use DIR the directory is there but it will not allow me to access it?
This has worked before. I have been using linux now for a few years and never had this problem before. It must be something stupid that I am doing.
I have folder in Downloads directory to which I need to navigate I'm doing "cd Downloads" and after "cd Folder1 " but terminal says "No such file or directory" how can I access that folder?
Dear All
I need your help.
I want to get a file from windows server using ftp.
Below is the script I have created but the connection is not established:
#!/bin/sh
lcd "directory in linux server"
USER="username of windows server"
PASS="password"
ftp -n "ip of windows server" <<EOF
user $USER $PASS
cd "C:\Users... directory in windows server where file is located"
bin
get test1234.txt
bye
EOF
I hope somebody can help me!
BR,