Sponsored Content
Top Forums Shell Programming and Scripting Reading file from remote host? Post 302773625 by jnojr on Thursday 28th of February 2013 10:53:06 AM
Old 02-28-2013
Because that will echo the value I want to stout, which doesn't do me any good... the value needs to be available to the script to echo out later. Every other value, which does not require root access, is loaded into a variable. There may be some other mechanism that can accomplish the same end, so I don't want to be fixated on variables.

ETA: You got me steered in the right direction, though! I wound up with:

Code:
  ssh $host ls /etc/cma.conf >/dev/null 2>&1
  if [ "$?" -eq 0 ]; then
    if [ -f /tmp/hbss.sh ]; then rm -f /tmp/hbss.sh; fi
cat >/tmp/hbss.sh <<EOF
#!/bin/bash
ssh -tt $host sudo grep CMABuildNumber /etc/cma.conf <<EOS
$SUDOPASS
EOS
EOF
    chmod 755 /tmp/hbss.sh
    HBSSVER=`/tmp/hbss.sh | grep CMABuildNumber | cut -d'>' -f2 | cut -d'<' -f1`
    #if [ -f /tmp/hbss.sh ]; then rm -f /tmp/hbss.sh; fi
  fi

It's messy and kludgy, but it works!

Last edited by jnojr; 02-28-2013 at 12:15 PM..
 

10 More Discussions You Might Find Interesting

1. Solaris

How to delete the files from local host to remote host

Hi all, i am copying .gz files from production server to development server using "scp" command.my requirement is after copying .gz files i want to delete old .gz files(two days back) in development server from production server. like this way i need to delelte .log ,.z and .dmp files... (3 Replies)
Discussion started by: krishna176
3 Replies

2. Shell Programming and Scripting

Reading from Remote Host

Hi I have a different architecture for my perl application. I have apache one server and data on another(not database). i need to read the data from other machine and that too securely. Also opening ports on apache machine is also restricted. Can anyone help me on this (2 Replies)
Discussion started by: Aditya_IT
2 Replies

3. Solaris

define .rhost file for tape backup to remote host

howdy experts, i am using 2 server- Solaris 5.9 i have tape device attached with 1 of my solaris server. But others not. # modinfo|grep tape 152 13d43e4 1333c 33 1 st (SCSI tape Driver 1.231) now i want to Backup DATA file and System File in Tape Drive. How do I take data and... (3 Replies)
Discussion started by: thepurple
3 Replies

4. Shell Programming and Scripting

running commands to remote host from centralized host

Gurus/Experts We have a centralized UNIX/Solaris server from where we can actually ssh to all other UNIX/Solaris servers...I need to write a script that reside on this centerlized server and do FileSystem monitoring (basically run df -h or -k) of other remote servers and then send an email to me... (6 Replies)
Discussion started by: anjum.suri
6 Replies

5. UNIX for Advanced & Expert Users

Help! How to find the local host after few ssh hops to remote host???

I do a ssh to remote host(A1) from local host(L1). I then ssh to another remote(A2) from A1. When I do a who -m from A2, I see the "connected from" as "A1". => who -m userid pts/2 2010-03-27 08:47 (A1) I want to identify who is the local host who initiated the connection to... (3 Replies)
Discussion started by: gomes1333
3 Replies

6. Shell Programming and Scripting

Polling for existence of file on remote host

I am polling a file on remote host. I have this code that works, but can't explain why it works. while user@remote.no-exist.com 'ls /user/app1/.done'` ] do echo Sleeping for 5 secs sleep 5; done This code works in the way that when the .done file exists on the remote host, the script... (1 Reply)
Discussion started by: starlatch
1 Replies

7. Shell Programming and Scripting

Not able to execute the file in remote host using except utility

I am automating the SFTP keys setp process: So i created the expect script for controlling the output of shell below is my main code: #!/usr/bin/expect set fd set password close $fd set df set app close $df spawn ssh servername << pb Pb file: set df set app close $df (4 Replies)
Discussion started by: Manoj Bajpai
4 Replies

8. Shell Programming and Scripting

Pause processes in remote host and resume execution in another remote host

Hi, Given addresses of 2 remote machines, using a shell script is it possible to get the state of running processes in "src" stop all the processes in "src" exit out of "src" ssh into "dest" resume the state of executing processes captured in step 1 in "dest" Assumption: "src" is... (3 Replies)
Discussion started by: Saeya Darsan
3 Replies

9. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

10. UNIX for Beginners Questions & Answers

SFTP file check through a remote host

Hi all, posting my first time, hope not breaking posting rules with it, if yes, let me know. I'm trying to build a script to check a file in an sftp server through a remote server. The intention is to check the file in a sftp host, and if the file is found or not, it should send an email.... (4 Replies)
Discussion started by: MrShinyPants
4 Replies
mktemp(1)							   User Commands							 mktemp(1)

NAME
mktemp - make temporary filename SYNOPSIS
mktemp [-dtqu] [-p directory] [template] DESCRIPTION
The mktemp utility makes a temporary filename. To do this, mktemp takes the specified filename template and overwrites a portion of it to create a unique filename. See OPERANDS. The template is passed to mkdtemp(3C) for directories or mkstemp(3C) for ordinary files. If mktemp can successfully generate a unique filename, the file (or directory) is created with file permissions such that it is only read- able and writable by its owner (unless the -u flag is given) and the filename is printed to standard output. mktemp allows shell scripts to safely use temporary files. Traditionally, many shell scripts take the name of the program with the PID as a suffix and used that as a temporary filename. This kind of naming scheme is predictable and the race condition it creates is easy for an attacker to win. A safer, though still inferior approach is to make a temporary directory using the same naming scheme. While this guaran- tees that a temporary file is not subverted, it still allows a simple denial of service attack. Use mktemp instead. OPTIONS
The following options are supported: -d Make a directory instead of a file. -p directory Use the specified directory as a prefix when generating the temporary filename. The directory is overridden by the user's TMPDIR environment variable if it is set. This option implies the -t flag. -q Fail silently if an error occurs. This is useful if a script does not want error output to go to standard error. -t Generate a path rooted in a temporary directory. This directory is chosen as follows: If the user's TMPDIR environment variable is set, the directory contained therein is used. Otherwise, if the -p flag was given the specified directory is used. If none of the above apply, /tmp is used. In this mode, the template (if specified) should be a directory component (as opposed to a full path) and thus should not contain any forward slashes. -u Operate in unsafe mode. The temp file is unlinked before mktemp exits. This is slightly better than mktemp(3C), but still introduces a race condition. Use of this option is discouraged. OPERANDS
The following operands are supported: template template can be any filename with one or more Xs appended to it, for example /tmp/tfile.XXXXXX. If template is not specified, a default of tmp.XXXXXX is used and the -t flag is implied. EXAMPLES
Example 1 Using mktemp The following example illustrates a simple use of mktemp in a sh(1) script. In this example, the script quits if it cannot get a safe tem- porary file. TMPFILE=`mktemp /tmp/example.XXXXXX` if [ -z "$TMPFILE" ]; then exit 1; fi echo "program output" >> $TMPFILE Example 2 Using mktemp to Support TMPDIR The following example uses mktemp to support for a user's TMPDIR environment variable: TMPFILE=`mktemp -t example.XXXXXX` if [ -z "$TMPFILE" ]; then exit 1; fi echo "program output" >> $TMPFILE Example 3 Using mktemp Without Specifying the Name of the Temporary File The following example uses mktemp without specifying the name of the temporary file. In this case the -t flag is implied. TMPFILE=`mktemp` if [ -z "$TMPFILE" ]; then exit 1; fi echo "program output" >> $TMPFILE Example 4 Using mktemp with a Default Temporary Directory Other than /tmp The following example creates the temporary file in /extra/tmp unless the user's TMPDIR environment variable specifies otherwise: TMPFILE=`mktemp -p /extra/tmp example.XXXXX` if [ -z "$TMPFILE" ]; then exit 1; fi echo "program output" >> $TMPFILE Example 5 Using mktemp to Remove a File The following example attempts to create two temporary files. If creation of the second temporary file fails, mktemp removes the first file before exiting: TMP1=`mktemp -t example.1.XXXXXX` if [ -z "$TMP1" ]; then exit 1; fi TMP2=`mktemp -t example.2.XXXXXX` if [ -z "$TMP2" ]; then rm -f $TMP1 exit 1 fi Example 6 Using mktemp The following example does not exit if mktemp is unable to create the file. That part of the script has been protected. TMPFILE=`mktemp -q -t example.XXXXXX` if [ ! -z "$TMPFILE" ] then # Safe to use $TMPFILE in this block echo data > $TMPFILE ... rm -f $TMPFILE fi ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of mktemp with the -t option: TMPDIR. EXIT STATUS
The following exit values are returned: 0 Successful completion. 1 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ SEE ALSO
sh(1), mkdtemp(3C), mkstemp(3C), attributes(5), environ(5) NOTES
The mktemp utility appeared in OpenBSD 2.1. The Solaris implementation uses only as many `Xs' as are significant for mktemp(3C) and mkstemp(3C). SunOS 5.11 10 Jan 2008 mktemp(1)
All times are GMT -4. The time now is 12:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy