Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2012
    Posts
    9

    Unanswered: ssh user@server<<EOJ cd path for i in * do echo $i done EOJ

    want to execute below the script for remote server.i am not able to execute below the script please help me urgent for this issue.i getting below the error
    ssh user@server<<EOJ
    cd path
    for i in *
    do
    echo $i
    done
    EOJ


    Pseudo-terminal will not be allocated because stdin is not a terminal.
    Sun Microsystems Inc. SunOS 5.10 Generic January 2005
    You have new mail.
    stty: : Invalid argument



    stty: : Invalid argument

  2. #2
    Join Date
    Feb 2006
    Posts
    173
    Provided Answers: 1
    Try it this way:
    Code:
    ssh user@server 'cd path; for i in `ls *`; do echo $i; done'

  3. #3
    Join Date
    Oct 2012
    Posts
    9
    ssh user@server ' cd path; j=0;for i in *;do;d=`du -sh $i | awk '{print( $1 )}'`;p=$d'|'$i;j=`expr $j + 1 `;arr[ $j ]=$p;echo ${arr[j]};done'
    please help me to resolve this issue.

  4. #4
    Join Date
    Feb 2006
    Posts
    173
    Provided Answers: 1
    Try it like this:
    Code:
    ssh user@server 'cd path; j=0; for i in `ls *`; do d=`du -sh $i | awk "{print $1}"`; p="$d|$i"; (( j+=1 )); arr[$j]=$p; echo ${arr[j]}; done'

  5. #5
    Join Date
    Oct 2012
    Posts
    9

    Hi script is working fine but $d value is not calculated .ssh user@server 'cd path; j

    Scripts working file .But $d value is not calculating.Please give me some altenate solution.

    i am calculating in $d only file size like file name is test.txt
    d=du -sh test.txt but it is giving size and file name also.
    ssh user@server 'cd path; j=0; for i in `ls *`; do d=`du -sh $i | awk "{print $1}"`; p="$d|$i"; (( j+=1 )); arr[$j]=$p; echo ${arr[j]}; done'

    Please help me for urgent base

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •