Linux.com

cloudsuser

cloudsuser

  • Linux.com Member
  • Posts: 7
  • Member Since: 30 May 10
  • Last Logged In: 04 Jun 10

Latest Posts

Posted by
Topic
Post Preview
Posted
  • cloudsuser
    cron job execution...
    $crontab -e * * * * * /root/cronJob.sh >> /root/cronJobExecuted.log [u][b]Source: cronJob.sh[/b][/u] sh /root/scheduledJob.sh [u][b]Source: scheduledJob.sh[/b][/u] One of my web application will keep on insert list of ssh command in my file "scheduledJob.sh" such as ssh -i key.pem root@ -C sh /mnt/monitor.sh >> /root/Output.txt ssh -i key.pem root@ -C sh /mnt/monitor.sh >> /root/Output.txt In remote machine, [u][b]Source: monitor.sh[/b][/u] echo `cat /mnt/imageOutput.txt` [u][b]Source: imageOutput.txt[/b][/u] line1 line2 As soon as when ssh get executed in scheduledJob.sh, I should not execute it again. How is should handle this... [u] [b]Example:[/b][/u] Cronjob has executed 1) ssh -i key.pem root@ -C sh /mnt/monitor.sh >> /root/Output.txt and 2)ssh -i key.pem root@ -C sh /mnt/monitor.sh >> /root/Output.txt Again when cronjob trying to execute, it should skip the above 2 ssh command , it should execute only the new command if and only if exist....How i can handle this ?
    Link to this post 03 Jun 10

    $crontab -e
    * * * * * /root/cronJob.sh >> /root/cronJobExecuted.log

    Source: cronJob.sh
    sh /root/scheduledJob.sh

    Source: scheduledJob.sh
    One of my web application will keep on insert list of ssh command in my file "scheduledJob.sh" such as
    ssh -i key.pem root@<host1> -C sh /mnt/monitor.sh >> /root/Output.txt
    ssh -i key.pem root@<host2> -C sh /mnt/monitor.sh >> /root/Output.txt

    In remote machine,
    Source: monitor.sh
    echo `cat /mnt/imageOutput.txt`

    Source: imageOutput.txt
    line1
    line2

    As soon as when ssh get executed in scheduledJob.sh, I should not execute it again.
    How is should handle this...

    Example:

    Cronjob has executed 1) ssh -i key.pem root@<host1> -C sh /mnt/monitor.sh >> /root/Output.txt
    and 2)ssh -i key.pem root@<host2> -C sh /mnt/monitor.sh >> /root/Output.txt

    Again when cronjob trying to execute, it should skip the above 2 ssh command , it should execute only the new command if and only if exist....How i can handle this ?

  • cloudsuser
    ssh accept "yes" in automation script possible ?
    ssh accept "yes" in automation script possible ? With the help of ssh i am executing the script... Before executing the ssh command, [b]at very first time i need to do ssh manually and typing "yes"[/b] to accept RSA key fingerprint...[color=#FF0000][b]Can we do it through automation by passing yes as an argument...[/b][/color] $ The authenticity of host 'hostname (xx.xx.xx.xx)' can't be established. RSA key fingerprint is 83:71:28:7c:55:38:28:4e:9e:51:32:57:19:9e:d2:d9. Are you sure you want to continue connecting (yes/no)? yes
    Link to this post 03 Jun 10

    ssh accept "yes" in automation script possible ?

    With the help of ssh i am executing the script...

    Before executing the ssh command, at very first time i need to do ssh manually and typing "yes" to accept RSA key fingerprint...Can we do it through automation by passing yes as an argument...

    $
    The authenticity of host 'hostname (xx.xx.xx.xx)' can't be established.
    RSA key fingerprint is 83:71:28:7c:55:38:28:4e:9e:51:32:57:19:9e:d2:d9.
    Are you sure you want to continue connecting (yes/no)? yes

  • cloudsuser
    ssh read output
    With the help of ssh i would like to execute script and redirect the output in my local file $ssh -i keypair1.pem root@ -C sh /mnt/monitor.sh >> /root/imgManagementOutput.txt [u][b]source: monitor.sh [/b][/u] echo `cat /mnt/imageOutput.txt` [u][b]Source: /mnt/imageOutput.txt[/b][/u] line1 line2 [u][b]Expected Output:[/b][/u] line1 line2 [u][b]Actual Output:[/b][/u] [color=#FF0000][b]line1 line2[/b][/color] I am looking for the output should be as "Expected Output" as it is not in a single line...
    Link to this post 03 Jun 10

    With the help of ssh i would like to execute script and redirect the output in my local file

    $ssh -i keypair1.pem root@<host> -C sh /mnt/monitor.sh >> /root/imgManagementOutput.txt

    source: monitor.sh
    echo `cat /mnt/imageOutput.txt`

    Source: /mnt/imageOutput.txt
    line1
    line2

    Expected Output:
    line1
    line2

    Actual Output:
    line1 line2

    I am looking for the output should be as "Expected Output" as it is not in a single line...

  • cloudsuser
    RE: ssh - execute the script remotely / File not found
    Thanks for your info. Please note , 1) The key is available. I can able to ssh(login) successfully with the help of key 2) ec2-create-volume is a command in $PATH What may be the issues ?
    Link to this post 31 May 10

    Thanks for your info.

    Please note ,

    1) The key is available. I can able to ssh(login) successfully with the help of key
    2) ec2-create-volume is a command in $PATH

    What may be the issues ?

  • cloudsuser
    RE: ssh - execute the script remotely / File not found
    As you said i tried with following option, 1) added "#!/bin/sh" in myScript.sh ssh -i key.pem root@ -C "sh /root/myScript.sh" [color=#FF0000][color=][b]Output: File not found: ''[/b][/color][/color] 2) $ssh -i key.pem root@ -C "/bin/sh ec2-create-volume --size 10 --availability-zone us-east-1a" [b][color=#FF0000]Output: File not found: ''[/color][/b]
    Link to this post 31 May 10

    As you said i tried with following option,

    1) added "#!/bin/sh" in myScript.sh

    ssh -i key.pem root@<host> -C "sh /root/myScript.sh"
    [color=]Output: File not found: ''[/color]


    2) $ssh -i key.pem root@<host> -C "/bin/sh ec2-create-volume --size 10 --availability-zone us-east-1a"
    Output: File not found: ''

  • cloudsuser
    RE: ssh - execute the script remotely / File not found
    As you said i treid with following command, $ssh -i key.pem root@ -C /root/myScript.sh [b][color=#FF0000][u]Output:[/u] File not found: ''[/color][/b] In remote machine, $ls -rtl myScript.sh $-rwxr--r-- 1 root root 59 May 30 12:31 myScript.sh [u][b]Source: myScript.sh[/b][/u] ec2-create-volume --size 10 --availability-zone us-east-1a [u][b]Note: [/b][/u] I can able to manually execute the command "ec2-create-volume --size 10 --availability-zone us-east-1a" successfully If i want to execute the same with ssh via script, how i should procede. Please help me on this.
    Link to this post 31 May 10

    As you said i treid with following command,

    $ssh -i key.pem root@<host> -C /root/myScript.sh
    Output: File not found: ''

    In remote machine, $ls -rtl myScript.sh
    $-rwxr--r-- 1 root root 59 May 30 12:31 myScript.sh

    Source: myScript.sh
    ec2-create-volume --size 10 --availability-zone us-east-1a

    Note: I can able to manually execute the command "ec2-create-volume --size 10 --availability-zone us-east-1a" successfully
    If i want to execute the same with ssh via script, how i should procede. Please help me on this.

  • cloudsuser
    ssh - execute the script remotely / File not found
    ssh - execute the script remotely / File not found: '' I am uisng amazon ec2-api-tool & ec2-ami-tool i was unable to execute through ssh. Getting error as File not found: '' The same script i can able to run directly in client machine successfully. Through ssh i was uanble to run the script remotely Source : myScript.sh ec2-create-volume --size $1 --availability-zone $2 $ssh -i key.pem root@myhost ./myScript.sh 10 us-east-1a File not found: '' Note: i have read write permission to my remote machine script myScript.sh What i might have done mistake...?
    Link to this post 30 May 10

    ssh - execute the script remotely / File not found: ''

    I am uisng amazon ec2-api-tool & ec2-ami-tool

    i was unable to execute through ssh.
    Getting error as

    File not found: ''

    The same script i can able to run directly in client machine successfully.

    Through ssh i was uanble to run the script remotely
    Source : myScript.sh
    ec2-create-volume --size $1 --availability-zone $2

    $ssh -i key.pem root@myhost ./myScript.sh 10 us-east-1a
    File not found: ''

    Note:
    i have read write permission to my remote machine script myScript.sh

    What i might have done mistake...?

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board