Generating a generic incremental code


 
Thread Tools Search this Thread
Operating Systems Solaris Generating a generic incremental code
# 1  
Old 06-24-2008
Generating a generic incremental code

Hi Gurus,

I have several Solaris systems (say system a, system b,system c) which will connect to a windows system (system Z) using SFTP session.

I have a 'txt' file on System Z , which has a simple numeric value on it(say 1) , If I have to increment this number with 1 (1+1 =2) irrespective of the source system . how do i do this.

Ex: I connect from system a to system Z , read the txt file get the number 1 , increment this number to 2 (1+1=2) . When I connect from system b or system c the number in txt file to be read should be 2, this number is once again incremented to 3 (2+1=3).
The Challenge: I'm unable to increment the file using the sftp session.

Please shed some light....

Thanks
Ram.
# 2  
Old 06-24-2008
i) what do you *really* want to do?
ii) depending on i) : beware of race conditions! They can hurt you! (ask google)
iii) break up into simple steps in bash code to be run on e.g. a:
Code:
scp Z:/dir/number.txt .
echo $[`cat number.txt` + 1] > number.txt
scp number.txt Z:/dir/

(depending on i) you should maybe use something able to look a file, e.g. a database or a tool on z called via ssh)

Last edited by fabtagon; 06-25-2008 at 04:43 PM.. Reason: markup fix - no other changes
# 3  
Old 06-25-2008
these are the only commands i can use on my sftp on system Z

sftp > help
Available commands:
cd path Change remote directory to 'path'
lcd path Change local directory to 'path'
chgrp grp path Change group of file 'path' to 'grp'
chmod mode path Change permissions of file 'path' to 'mode'
chown own path Change owner of file 'path' to 'own'
help Display this help text
get remote-path [local-path] Download file
lls [ls-options [path]] Display local directory listing
lmkdir path Create local directory
lpwd Print local working directory
ls [path] Display remote directory listing
lumask umask Set local umask to 'umask'
mkdir path Create remote directory
put local-path [remote-path] Upload file
pwd Display remote working directory
exit Quit sftp
quit Quit sftp
rename oldpath newpath Rename remote file
rmdir path Remove remote directory
rm path Delete remote file
!command Execute 'command' in local shell
! Escape to local shell
? Synonym for help

Now,
How to read the contents of the number.txt on system Z ???

I tried using the !cat number.txt, but it says file not found...
# 4  
Old 06-25-2008
Try to actually understand what I've written, so you
i) won't have such problems using answers on this board
ii) will be able to help yourself in the future

You should run those commands on e.g. a, not z.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Incremental numbering?

Would it be possible for a script to duplicate a file and incrementally number it? File in: XXX_007_0580_xxxx_v0016.aep File out: XXX_007_0580_xxxx_v0017.aep If someone knows of a way I'd love to see it. Thanks! (7 Replies)
Discussion started by: scribling
7 Replies

2. Shell Programming and Scripting

Delimiter Conversion(Generic Code)

Hi All, I am looking for a generic code which can search for the existing delimiter(what ever it may be) in a file and convert it to Pipeline. The file may have Pipeline delimiter already in that case just leave it. Please find below some sample records. Sample records1: ... (2 Replies)
Discussion started by: Arun Mishra
2 Replies

3. Shell Programming and Scripting

auto-generating assembly code by variables found by script

Hi everybody I'm working on a list of registers(flip-flops to be exact), now i need to extract some value from this list and use them as arguments to pass them to some assembly code for example i have: 118 chain79 MASTER (FF-LE) FFFF 1975829 /TCK F FD1TQHVTT1 ... (1 Reply)
Discussion started by: Behrouzx77
1 Replies

4. Shell Programming and Scripting

FULL or INCREMENTAL ???

Hi. Can someone tell me if the following script that i have made is a script for INCREMENTAL BACKUP or FULL BACKUP. My teacher told me that is doing an FULL BACKUP. • find /etc /var /home -newer /backups/.backup_reference > /backups/.files_to_archive • touch /backups/.backup_reference • tar... (1 Reply)
Discussion started by: bender-alex
1 Replies

5. Windows & DOS: Issues & Discussions

Incremental Backup

I have a folder /root/test in a centos 5.3 system. I want to take an incremental backup of the contents of the folder in the C:\Downloads folder of a windows system present in the same lan as the linux system. What are the ways of executing this plan? Kindly help (0 Replies)
Discussion started by: proactiveaditya
0 Replies

6. UNIX for Dummies Questions & Answers

incremental by 1

let says, i have this number as 000002080, i want to add 1 to make it 000002081, and then i want to add 1 to 000002082, add 1 to 000002083, 84. i=000002080 TOT=$(echo "scale=9; $i + 1" | bc) echo $TOT it shows 2081, i want to retain 000002081, 000002082, 000002082, 000002084. (2 Replies)
Discussion started by: tjmannonline
2 Replies

7. UNIX for Dummies Questions & Answers

incremental backup

Hi All.. i am trying to write a script which will give the incremental tar backup of all files with latest timestam. i tried with find -mmin -2 but if it takes half on hour or something to creat the tar itself, then no meaning in using the above command. so please help me to find the... (2 Replies)
Discussion started by: Usha Shastri
2 Replies

8. Shell Programming and Scripting

why is this code generating syntax error?pls help

#!/bin/sh copy() { source=`stat -c %s $1` dest=0 cd $2 while ;do cp $1 $2 & pct=`((100 * $dest) / $source )` dest=`dest+1` echo -en ".$pct%\b\b\b" sleep 1 done } echo "starting now" copy /file1 /tmp (3 Replies)
Discussion started by: wrapster
3 Replies
Login or Register to Ask a Question