comands inside the script


 
Thread Tools Search this Thread
Special Forums Cybersecurity comands inside the script
# 1  
Old 02-13-2008
comands inside the script

hi,

i want to put a set of commands inside a script and executing commands sequentially. there are 2 commands, the first command copies the program from my machine to another machine, execute it and get the result on my machine. the second command removes the program which was copied to the remote machine. I have already made the ssh authentication. I need to integrate both of them in one single script so that if i run that script it gives the result. Can somebody give some suggestions?

first command
Code:
cat /path of my machine/script.pl | ssh user@remotemachine "cat > /path of the remote server where the file is copied/backup_script.pl ; perl /path of the remote server where the file is copied/backup_script.pl

second command: removing the file after executing

Code:
ssh user@remotemachine rm /path of the remote server where the file is copied/backup_script.pl

thanks.
# 2  
Old 02-13-2008
Instead of using cat and piping, couldn't You just do something like:
Code:
#!/bin/sh
scp script.pl user@remote:
result=$(ssh user@remote script.pl)
ssh user@remote rm script.pl
echo $result

# 3  
Old 02-13-2008
Thanks a lot Lakris...

Code:
#!/bin/sh
scp script.pl user@remote:remote path
result=$(ssh user@remote script.pl)
echo $result
ssh user@remote rm script.pl

i jus swapped the last 2 lines of ur script, cuz it deletes the file before it gets executed.

thanks.
# 4  
Old 02-13-2008
NP,

Yes but the content of result is in Your local machine, isn't it? And that doesn't get deleted until You end the script.
Smilie

/L
# 5  
Old 02-13-2008
Quote:
Originally Posted by Lakris
NP,

Yes but the content of result is in Your local machine, isn't it? And that doesn't get deleted until You end the script.
Smilie

/L
ohhh k... i got it ....

thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

2. Shell Programming and Scripting

How to merge Expect script inside shell script?

Hi I have two scripts one is Expect and other is shell. I want to merge Expect code in to Shell script so that i can run it using only one script. Can somebody help me out ? Order to execute: Run Expect_install.sh first and then when installation completes run runTests.sh shell script. ... (1 Reply)
Discussion started by: ashish_neekhra
1 Replies

3. Shell Programming and Scripting

Use of the below ftp comands

plz let me know what the below ftp is doing it . ftp -m amazon-d . -i /test/load/y748_W*.stc (1 Reply)
Discussion started by: ramkumar15
1 Replies

4. UNIX for Dummies Questions & Answers

Execute multiple comands on one single line

hi, I have a litle problem i wish to excute this comand : ./test.sh -e txt /home -l a so what it says is that "-e" shows me all the extenions that are ".txt" in "home" this works but then i wish that "-l" will show all files begining in this case with the letter "a" . Both comands work... (5 Replies)
Discussion started by: samirboss
5 Replies

5. Shell Programming and Scripting

Script Help - Multi Comands

Hi guys I am trying to get a bunch of lines into a .sh script that will let me easily run a bunch of commands on its own without me having to be there... I have done this with other things but apparetnly it doesn't like to use yum.. I will post my script you will see what im trying to do.. ... (3 Replies)
Discussion started by: Bigstack
3 Replies

6. Shell Programming and Scripting

Running a unix script(which is calling another script inside that) in background

Hi all, I am having a script ScriptA which is calling a script ScriptB in the same server and copying files to second server and have to execute one script ScriptC in the second server. THis First script ScriptA is the main script and i have to execute this process continously. for Keeping... (2 Replies)
Discussion started by: rohithji
2 Replies

7. Solaris

Solaris 10 network, process, database related comands

Hi everbody, Can anyone let me know the resources for list of network, process, database related commands of solaris10 possibly with little bit of explanation. Thanks in advance, Chandra Sekhar. (1 Reply)
Discussion started by: chandoo.java
1 Replies

8. UNIX for Advanced & Expert Users

For Loops Within Ftp Comands

I am having trouble getting files to ftp over when I run the file names through a loop. If I just do one file it works, but inside of a for loop it does not. Help! ################section 2 cd /home/salazar/chk_data chmod 777 * ftp -n 161.241.--.-- <<! user anonymous \n ascii for... (6 Replies)
Discussion started by: jsalz638
6 Replies

9. Shell Programming and Scripting

how to identify the type of shell using comands..

Dear friends, please tell me how to identify the type of the shell (whether cShell, kshell or anything else) please tell me the command. waiting for ur reply.... regards, swamymns (2 Replies)
Discussion started by: swamymns
2 Replies

10. Programming

External comands in C?

Hey all, I'm writting my first C program (Apart from the little ones I did to learn the program). What I want for this program to do is ping a range of IP's and then place the reply if alive into a file the compare all in that file to the /etc/hosts file to find the host name. I know I... (2 Replies)
Discussion started by: merlin
2 Replies
Login or Register to Ask a Question