Editing a file on remote server using shell script locally


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Editing a file on remote server using shell script locally
# 1  
Old 08-15-2013
Editing a file on remote server using shell script locally

Hi Scott,

My previous post was not for any school or college projects. I am currently working with a IT company (Cannot provide more details than this). I am trying to implement the below script in my day-to-day work,

Apologies for the confusion in previous post Smilie. My question remains same

1. Building a shell script which connects to a remote server
2. running script on local machine as user 'A'
3. connecting to server using user 'B' with password
4. login with a powerbroker role 'P' (asks for same password as 'B') on that server
5. edit a file and save it
6. Exit from server

Thanks,
Nishant
# 2  
Old 08-15-2013
Quote:
Originally Posted by Nishant Ladiwal
Hi Scott,

My previous post was not for any school or college projects. I am currently working with a IT company (Cannot provide more details than this). I am trying to implement the below script in my day-to-day work,

Apologies for the confusion in previous post Smilie. My question remains same

1. Building a shell script which connects to a remote server
2. running script on local machine as user 'A'
3. connecting to server using user 'B' with password
4. login with a powerbroker role 'P' (asks for same password as 'B') on that server
5. edit a file and save it
6. Exit from server

Thanks,
Nishant
2 questions.
a) What do you mean by a powerbroker role 'P'?
b) What kind of edition do you want to make to that file in the remote host? Will you be adding / deleting text, dates, logs... etc?
# 3  
Old 08-15-2013
Thanks for your reply
Answers:
2. Powerbroker is a kind of privileged access management. Users will be added to that group that will have certain elevated privileges. In this case, user 'B' is added to the powerbroker group 'B' that has certain roles/privileges. Users can edit the file only after sudo'ing pb 'B'.
3. I want to comment 2 lines and uncomment other 2 lines in that file and save the file.

Hope this helps
# 4  
Old 08-15-2013
Quote:
Originally Posted by Nishant Ladiwal
I want to comment 2 lines and uncomment other 2 lines in that file and save the file.
I am beginning to think that this will be harder than I first thought (if you're looking at automating this thing). Can you please provide an example of that file, BEFORE and AFTER you edit it?

Also, what OS / version are you on?
# 5  
Old 08-15-2013
This files provides the Oracle database schema username and password that the application should use while running

dname=somedb
#<Option 1 >
#schema1username=schema1
#schema1password=schema1pwd
#<Option 2>
schema2username=schema2
schema2password=schema2pwd

I have to uncomment the <Option1 > username and password and comment <Option 2> username and password. Then I have to start the application.

Its RHEL 5.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To run a shell script in remote server from windows batch file

Hi all, i need to run a shell script on remote server. I have created file .bat file in windows server with following code, c:\Users\Desktop\putty.exe -ssh -pw password user@server ./script.sh i need to run the script.sh in my remote server Above command is not working, any... (4 Replies)
Discussion started by: rammm
4 Replies

2. Shell Programming and Scripting

Editing a file on remote server using shell script locally

Hi All, I have below requirements for my project: 1. Building a shell script which connects to a remote server 2. running script on local machine as user 'A' 3. connecting to server using user 'B' with password 4. login with a powerbroker role 'P' (asks for same password as 'B') on that... (1 Reply)
Discussion started by: Nishant Ladiwal
1 Replies

3. Shell Programming and Scripting

Shell quoting problem while editing a remote file using sed

value of i = solarisbox ssh $i "cat /etc/hosts | sed "s/$i\.local\.//" | sed "s/$i\./$i/" | sed "s/$i/$i.sol.com/" > /usr/users/chidori/edit_hosts"While running the above one liner its i am not able to make the changes and write it to the file /usr/users/chidori/edit_hosts . I know there is a... (2 Replies)
Discussion started by: chidori
2 Replies

4. Shell Programming and Scripting

Shell script to read from a file and update remote server

Its a tough one and would appreciate any guidance for a script that i am trying to develop....Again I do understand its a complicated script and help would be greatly appreciated.... Thank you 1- Need to check for a file (in a certain location on a server) every 15 minute or so if it is there... (4 Replies)
Discussion started by: aavam
4 Replies

5. Shell Programming and Scripting

Reading file from remote system and work on it locally

Hi! I am still fairly new to shell programming, but I have taken an interest to it and want to try some new stuff. I intend to make a shell script (using bash) to read a file on a remote system, then do some work on it on the local system and display it. In the long run I want to have a... (9 Replies)
Discussion started by: aaOzymandias
9 Replies

6. Shell Programming and Scripting

How to FTP the latest file, based on date, from a remote server through a shell script?

How to FTP the latest file, based on date, from a remote server through a shell script? I have four files to be FTP'ed from remote server. They are of the following format. build1_runtime_mmddyyyy.txt build2_runtime_mmddyyyy.txt build3_runtime_mmddyyyy.txt buifile_count_mmddyyyy.txt ... (9 Replies)
Discussion started by: imran_affu
9 Replies

7. Shell Programming and Scripting

Use cURL in shell script and get most recent file from remote server using SFTP

I have been trying to implement the following shell script -- sftp to remote server get list of files in the directory sftp get the most recent listed file exit This script will be scheduled to be executed everyday using CRON or CONTROL-M and the need is to have absolutely no human... (7 Replies)
Discussion started by: toobrown1
7 Replies

8. Shell Programming and Scripting

editing a file using shell script

HI all, I have file in the below format 1111111111_222222222_3333333 111111_22222_33333 11111111_222222_33333333333 i need to display this file like this 2222222_1111111111 22222_11111111 22222222222_1111111111111 can anyone help me with this Thanks in advance (1 Reply)
Discussion started by: saravanan71184
1 Replies

9. UNIX for Dummies Questions & Answers

Pull a file from a remote server through a shell script

Hi, I am writing a shell script to pull a file from a remote server (Let say its a windows based remote server). One of my criteria is to pull a file only if it is not empty. We have done a similar script to push a file from our end to a remote server and before pushing it we check for the... (2 Replies)
Discussion started by: sashankkrk
2 Replies

10. UNIX for Dummies Questions & Answers

Editing a file in a shell script

Using Solaris 8. I need to create a shell script that will edit a text file. I need to look in the text file and do a search and replace. For instance, the text file name is always 'filename'. I need to open filename and replace every instance of 'oldtext' with 'newtext'. 'oldtext' is static. ... (3 Replies)
Discussion started by: jowpup
3 Replies
Login or Register to Ask a Question