I need to edit a xml file in a server. How can I navigate to the path where the file is present in the server and edit it using putty commands. I am new to unix so if anyone could help me out.
To move around in linux you need to use the change directory command which is: cd /location/of/directory/. If you then need to edit a file there are a number of editors which you can use. My preference is VIM which can be used by doing the following vi file.xml. Although VIM is not recommended if you are new to unix. Try using nano filename.xml instead if this makes it easier for you.
If you wish to edit a file directly without having to move to it's directory you can just do: nano /path/to/file.xml
Related
so I've recently learned about sudoedit and how I can edit a file more safely than the standard "sudo vim".
the problem is now, when I'm in vim and "vsplit" or "tabnew" I open it as my user account (no root privileges)
sudoedit launches a separate instance of Vim, because it has to manage the lifecycle of the editing session; i.e. write back the edited temporary file with root priviledges. It cannot achieve that from a running Vim session.
However, there are plugins that achieve sudoedit-like functionality, for example the aptly named SudoEdit.
Maybe you just want a option to save file as sudo.
You can find mapings for write file as sudo or use tpope enuch plugin.
You will get :SudoWrite and :SudoEdit commands and couple more.
vim-enuch
I'm writing a script to create virtual hosts in Mamp Pro. I want them to be created and appear in the GUI next to the normal ones I've created manually through the GUI. I've found the following questions on SO:
Automatic Virtual Hosts with MAMP Pro?
Add MAMP Pro Vhosts with script
Here are my findings, so far:
I've found out that the hosts appearing in the MAMP Pro GUI are found in: ~/Library/Application\ Support/appsolute/MAMP\ PRO/settings3.plist; I've tried editing it but I can't seem to get the entries right with the command PlistBuddy -c 'print ":virtualHosts"' settings3.plist which says Print: Entry, ":virtualHosts", Does Not Exist
From the second question I've listed above, I found out that I can edit the httpd.conf files (one found in user library and one in the root library) through the GUI.
The hosts file including all of the IP addressing is in /private/etc/hosts
The questions are dead, even though I commented on the latest one asking for an update on how he solved his scripting problem in the end.
In the end, I can easily add the values into the hosts file and the vhosts.conf files to make the website work. My only problem is getting it to show up in the list with the other virtual hosts in the MAMP Pro GUI.
Update: After further investigation and experimentation, I realized the process in which the virtual hosts are created; when I first create a host through the GUI, the settings3.plist file gets updated, when I hit "save" to save the changes, the hosts and httpd.conf files are updated accordingly. I understand that settings3.plist can be converted to an XML through plutil -convert xml1 -o - settings3.plist > test.txt and then edit it and convert it back to binary through plutil -convert binary -o - test.txt > settings3.plist.
My problem with that is that, even though I got the gist of how the CP$UID works in the XML formats, I cannot create a script to undestand the concept, check for the position of the values through the list, and then put in the values accordingly. I even asked a question about it here: https://stackoverflow.com/q/33775025/1934402
The solution provided in Automatic Virtual Hosts with MAMP Pro? refers to MAMP PRO version 2.x where host configuration is saved in settings.plist which is an XML format property list file while in MAMP PRO version 3.x host settings are stored in settings3.plist which is a binary format property list file.
Even in this format you should be able to do:
/usr/libexec/PlistBuddy -c Print settings3.plist
and still get the contents of the file. Your problem arises from the fact that virtualHosts is no longer there as you will see by running the above command. The above command output is not very helpful for understanding the structure of your plist file so you could run:
plutil -convert xml1 -o - settings3.plist > ~/settings3.plist.xml
and then work out the structure of ~/settings3.plist.xml in order to find out which keys to use in PlistBuddy commands. It is a good idea to check the manual pages for plist and PlistBuddy. Do note that key names have changed and the structure is not that clear even in the xml file.
I hope this helped. I will investigate further into it and modify this answer if I have a full recipe for editing host details.
I am trying to create a bridge network. My problem is I can not find /etc/xend/xend-config.sxp file on my xenserver.
Can someone give me a hand? Someone knows where can I find xend-config.sxp file?
Note: I'm using Xenserver 6.5.
Firstly I assume you have connected to your server through a terminal, likely using ssh.
Use the command cd /etc/xend/ This will change the directory into this folder.
To see the contents of the folder type ls. If there is anything in the folder, such as the xend-config.sxp file it will show up.
If the file does not show up you can create it. It often seems to be the case that configuration files need to be created by one self the first time.
You can do this by running the command touch xend-config.sxp
Running the command ls should now show you the file. Running pwd will show you that it has been created at /etc/xend/
To edit the file you can use an editor such as nano or vim or whatever is your personal choice, e.g. sudo nano xend-config.sxp will open the file xend-config.sxp in a nano text editor.
I hope this helps
I have a file loaded in R that I want to move to a samba share
It is something like
write(some-file, file = "|smbclient -U user //ip password")
It connects to the samba but then (I think) the output is "executed" in the smb: \> and I don't want the file to be executed, I don't know how to pass the file to the destination with a putfunction inside smbclient.
Edit: This is not the same problem as the first post. The first post is solved and answered by me. The point there was connecting to samba. Now I'm already connected to it but the write() function doesn't make a file, instead it pipes out the words separately. I just wanted to know how to make it create a file in a sentence.
I found the answer by changing the philosophy:
First, I write the file locally, like
write(some-file, there)
Then I use the system() function to call smbclient and put the file already written
system("smbclient -U user //ip/dir password -c \"put some-file some-file\"")
My script is more complex and it's inside a Shiny app but in summary that's the solution
I am following a tutorial for ruby on rails and in the video the guy opens the directory we are currently inside in terminal as a textmate project. I am not sure how to do this.
When you are in a directory in terminal, to open all files in TextMate, use
mate .
If you want to open a single file, use
mate <the file name>
You can use the mate terminal command, see how to use it here:
http://manual.macromates.com/en/using_textmate_from_terminal.html
HTH
If you are using the textmate 2, it comes with this command line utility. What you need to do is turn it on.
Go to "Preferences", and then "Terminal" to turn on.
See http://blog.macromates.com/2011/mate-and-rmate/