Problem in appending text to a file located in remote server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in appending text to a file located in remote server
# 1  
Old 05-27-2012
Problem in appending text to a file located in remote server

Code:
ssh -q "server_name sudo echo 'dbagroup::1234' >> sudo /etc/group"

if i execute the above code its not getting appended.

my requirement is to login to remote server and append dbagroup::1234 in /etc/group i am able to achieve this with tee -a command

want to know why its not working with >> operator
# 2  
Old 05-27-2012
Hi,
What the error thrown. I think the below code will work
Code:
 ssh -q "server_name `sudo echo 'dbagroup::1234'` >> sudo /etc/group"

# 3  
Old 05-27-2012
sorry its not working.. problem is i am trying to append the text to the remote server. but in my case its getting appended to the server from where i am trying connect to the remote server
# 4  
Old 05-27-2012
Code:
ssh server_name "sudo echo 'dbagroup::1234' >> /etc/group"

# 5  
Old 05-28-2012
sorry not working .. i am getting error

Code:
ksh: /tmp/hello: cannot create

Code:
# ls -ld /tmp/hello
rw-r--r-   1 root     sys           15 May 28 07:03 /tmp/hello

# 6  
Old 06-21-2012
I'm having the same issue. Were you able to get it working?
My code is in perl but it is attempting to accomplish the same thing:
Code:
system("/usr/bin/ssh -q -o BatchMode=yes $hostname sudo \"echo $linuxSudoTTY >>/tmp/sudoers\"");


Last edited by Franklin52; 06-21-2012 at 02:13 PM.. Reason: Please use code tags for data and code samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP problem......File not getting from Remote server

Hi, We are using one unix script which is using sftp command and connect to remote server and get some file form remote server. some time after running this script we are not getting any file . Could you please tell us detailed validation that is there any problem with... (6 Replies)
Discussion started by: maheshkumar93@g
6 Replies

2. Shell Programming and Scripting

Appending 2 text files - Problem in windows

Hello, I have text files to append and am able to do with cat. cat file1 file2 >file3 and file3 works fine in UNIX (checked with vi and it looks fine) but when i open the same file in windows I see 2nd file appended as a single-line. In other words, all the lines of 2nd file appended to... (2 Replies)
Discussion started by: magnus29
2 Replies

3. IP Networking

Execute script located on a remote machine

So, is there way of automating this ? My ultimate goal is to run some cmd script in windows and it should connect to a remote unix host and run a script x.sh located on the remote unix host. I was wanting to achieve this by using WinSCP and Putty only. If possible let me know how and if not... (25 Replies)
Discussion started by: mohtashims
25 Replies

4. Shell Programming and Scripting

Appending text to a file

Hi, Want to append the text to a new file, echo "set `sqlplus -S abc/xyz123@localdb<<EOS" >> chk_test_append.sh echo "EOS`" >> chk_test_append.shbut getting the below error : what wrong is written ? With Regards (4 Replies)
Discussion started by: milink
4 Replies

5. Shell Programming and Scripting

Need help to change the content for remote located file

Hi All, I have a file that sits on 4 diffrent servers, those servers are diffrent region based and they are authentication protected and that file has a diff port numbers, so when run the script it must ask my login details,region of server and port no for that file once it took from me it... (1 Reply)
Discussion started by: tmarjuna
1 Replies

6. UNIX for Advanced & Expert Users

Need help to change the content for remote located file

Hi All, I have one file that sits on 4 diffrent servers, those servers are diffrent region based and they are authentication protected and that file has a diff port numbers, so when run the script it must ask my login details,region of server and port no for that file once it took from me... (1 Reply)
Discussion started by: tmarjuna
1 Replies

7. Shell Programming and Scripting

ssh text into file on remote server

Hello, I have about 90 servers that I need to update snmp configs. I am trying to write a script that will echo 4 new lines of text into the snmpd.conf file. I have tested it locally and it works when the server ssh into itself but when I try to run the script to ssh into a remote server it logs... (5 Replies)
Discussion started by: mr_dthomas
5 Replies

8. Shell Programming and Scripting

unix shell script which inserts some records into a file located in remote servers...

All, I need to write an unix shell script which inserts some records into a file located in remote servers. * Get the input from the user and insert according the first row. It should be in ascending order. 123451,XA,ABA 123452,XB,ABB 123453,XC,ABC 123455,XE,ABE 123456,XF,ABF 123458,XG,ABG... (2 Replies)
Discussion started by: techychap
2 Replies

9. Shell Programming and Scripting

Deleting a file located on another server

Hi, I have successfully copied a file from one server to another using following command. user1@server1# scp test.jsp user2@server2:/home/ Now i want to delete that copied file(test.jsp) from "server2" by running some command from server1. Please help... (2 Replies)
Discussion started by: SanketJOSHI
2 Replies

10. UNIX for Dummies Questions & Answers

Deleting a file located on another server

Hi, I have successfully copied a file from one server to another using following command. user1@server1# scp test.jsp user2@server2:/home/ Now i want to delete that copied file(test.jsp) from "server2" by running some command from server1. Please help... (1 Reply)
Discussion started by: SanketJOSHI
1 Replies
Login or Register to Ask a Question