Sponsored Content
Top Forums Shell Programming and Scripting How to save and execute terminal commands in shell? Post 302761125 by Akshay Hegde on Friday 25th of January 2013 06:15:05 AM
Old 01-25-2013
How to save and execute terminal commands in shell?

I frequently use some commands, which I want to save in some file say
Code:
myregularshell.sh

these are the commands I use, I tried saving and executing, but couldn't get the preview of execution, and result is also not coming if I copy same commands and paste it on terminal result is coming


Code:
cd go somewhere

echo "I am here $PWD"

sudo su

source /etc/profile

sh operation.sh arguments

echo "Operation over"

find /mypath/path iname "*.abc" -delete

echo "old files deleted"

mv -i *.xyz /mypath/path 

echo "new files moved "


Is there any way to save as shell script and execute ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to execute shell commands in awk script?

Greetings Friends, Suppose I wish to invoke some shell level commands inside an awk script how to do that? say I wish to use : "wc" on a record to count number of characters in a record Any clues? Thanks, Rishi (1 Reply)
Discussion started by: RishiPahuja
1 Replies

2. Solaris

terminal output - save to file?

I have a window open on my ultra 10 - a terminal window connecting to a server. Is there any way I can log all output to this window to a log file on my ultra 10 ? (2 Replies)
Discussion started by: frustrated1
2 Replies

3. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

4. Shell Programming and Scripting

execute shell commands with in sftp

Hi All, Please let me know how do I execute some of the shell commands like cat, find ,grep within sftp. Any help in this regard would be greatly appreciated. Thanks, (5 Replies)
Discussion started by: tommy1
5 Replies

5. OS X (Apple)

Help w/ save and executing terminal actions

Hey everyone, Being new to the deeper levels of OS X and UNIX I am hoping the bright minds on the board could push me in the right direction. On a daily basis I work as a CG Generalist (creating 3D for film) and I am using a 3th party render engine with my main 3D program (Autodesk Maya)... (0 Replies)
Discussion started by: SofusGraae
0 Replies

6. Shell Programming and Scripting

Shell script to execute commands in individual users' home directories

Hi, I am trying to write a shell script which execute certain commands within certain folders in each user's home directories I started off with a bash script - #!/bin/csh -f su -l cvsusr1 cvs -d /home/cvsadm/repository status But the shell script finishes immediately after... (1 Reply)
Discussion started by: rupa_lahiri
1 Replies

7. Shell Programming and Scripting

Shell: How to execute commands from another file?

I made a configuration file for my shell script in that all the values that the shell scipt needs, are defined, but I don't know how to let the shell script use those defined variables. Thank you for your help :) (3 Replies)
Discussion started by: Alkali
3 Replies

8. Shell Programming and Scripting

Shell script help to execute ssh remote commands

Hi, The below command is not giving me the count , Can somebody help me in re-writing this pls . Proc_Exist=`ssh -q -o "BatchMode=yes" -o "PasswordAuthentication=no" $OAUSER@${Primary_Node} ps -ef | grep -v grep | grep "${ICM_Proc}" |wc -l ` Also the same problem with below... (13 Replies)
Discussion started by: Y.balakrishna
13 Replies

9. Shell Programming and Scripting

Running q-shell commands( on IBM-i Series) from cygwin terminal (on windows)

I have cygwin installed on windows server and when I do echo $SHELL the output is /bin/bash I have created a ssh tunnel from this windows server through cygwin to ibm -i series which is running Q-shell. I am trying to invoke a utility wsadmin (used for scripting) on ibm-i from the... (12 Replies)
Discussion started by: gaurav99
12 Replies

10. Shell Programming and Scripting

How to execute application commands with shell script?

Hi Friends, We have a application "getstatus" which needs to run on application prompt. But it is not working with shell script. Example: Unix Root Prompt# execute "crp" to go to application prompt CRP>getstatus displays output of app health CRP>exit Unix Root Prompt# Script , which... (2 Replies)
Discussion started by: suresh3566
2 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 10:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy