- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: shell script help (ftp)
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2012 02:16 AM
07-14-2012 02:16 AM
shell script help
i was write one script for file transfer
script
ftp -d -n -i -v 10.40.40.26 <<EOT
user admin Welcome456
lcd
put *.txt
the above sciprt upload *.txt file to one window FTP account. i want to upload the (/home/rajesh )in this path we have 5 files , i want to upload today created files not folder , how to write the script
- Tags:
- ftp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2012 03:32 AM - edited 07-16-2012 06:37 AM
07-14-2012 03:32 AM - edited 07-16-2012 06:37 AM
Re: shell script help (ftp)
>I want to upload today created files
You can put the files modified today:
ftp -n -i -v 10.40.40.26 <<EOF
user admin Welcome456
prompt
lcd directory
mput $(find . -type f -mtime -1)
EOF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2012 01:33 AM
07-16-2012 01:33 AM
Re: shell script help
more file3
Only in file2: data
i want to tranfer the file called data
pls find the below command is not working, please help me
put $file3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2012 02:49 AM - edited 07-16-2012 02:49 AM
07-16-2012 02:49 AM - edited 07-16-2012 02:49 AM
Re: shell script help
So you're finding the differences between file1 and file2, and saving the list of differences to file3.
You show that the content of file3 is literally:
Only in file2: data
Your command "put $file3" does not work because there is no environment variable named "file3": environment variables are not the same as files.
The diff command also produces output like "Only in <name>: <filename>" only when <name> is a directory. So I guess file1 and file2 are actually directories.
A different syntax could be used to read the contents of file3 and use them on the command line. There are two ways to do this:
put $(cat file3)
put $(< file3)
If file3 has the content you showed, this would result in a command like "put Only in file2: data", which will not work. You would have to remove the "Only in file2: " part before using the rest to build your "put" command. And if the current working directory of the "put" command is the same as when you ran the "diff" command, the command you actually need is more likely "put file2/data".
If it is guaranteed that the diff command will always identify one and only one file for transfer in directory file2, you might do something like this:
put file2/$(grep "^Only in file2:" <file3 | awk '{print $4}')
To understand this, you must look inside the $( ... ) construct first.
First, the grep command will find the right line in file3, ignoring any other lines in the file, and piping the right line to awk. The awk command will pick the 4th word from the line, ignoring everything else. This should be the word "data". Now, the entire $( ... ) construct will be replaced with the awk output, i.e. the command line will ultimately be equivalent to:
put file2/data
If there might be more than one file to transfer, you would need to do something like this: (the reason why there was no need to put ../file3 instead of file3 is left as an exercise for the reader :-)
diff file1 file2 > file3
ftp -n -i -v 10.40.40.26 <<EOT
user admin Welcome456
prompt
lcd file2 mput $(grep "^Only in file2:" <file3 | awk '{print $4}')
EOT
- Tags:
- command substitution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2012 06:34 AM - edited 07-16-2012 06:36 AM
07-16-2012 06:34 AM - edited 07-16-2012 06:36 AM
Re: shell script help (ftp)
>There are two ways to do this:
No need to mention using an evil cat. ;-) $(< file3) is the "right" way for a real shell.
You could combine the diff, grep and awk into one:
mput $(diff file1 file2 | awk '/^Only in file2:/ {print $4}')
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2012 10:22 AM
07-16-2012 10:22 AM
Re: shell script help (ftp)
from mattia advise today i created the script , but mput not upload two file, it will upload only one file.
dennis tomorrow i try your script , if any doubt i will touch you ,thanks once again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2012 07:53 PM
07-16-2012 07:53 PM
Re: shell script help (ftp)
please find the output
diff wel sur | awk '/^Only in sur:/ {print $4}'
data1
data2
but we when he execute the scruipt data1 only upload.
pls advise
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2012 08:20 PM
07-16-2012 08:20 PM
Re: shell script help (ftp)
i need data1 data2,
but the output comes
data1
date2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2012 09:45 PM
07-16-2012 09:45 PM
Re: shell script help (ftp)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2012 10:22 PM - edited 07-17-2012 12:05 AM
07-16-2012 10:22 PM - edited 07-17-2012 12:05 AM
Re: shell script help (ftp)
>but the output comes (separate lines)
Oops. Either we need to change the newline to a space, use printf or just have multiple puts:
ftp -n -i -v 10.40.40.26 <<EOF
user admin Welcome456
lcd file2
$(diff file1 file2 | awk '/^Only in file2:/ {print "put", $4}') # separate puts
EOF
ftp -n -i -v 10.40.40.26 <<EOF
user admin Welcome456
prompt
lcd file2
mput $(diff file1 file2 | awk '/^Only in file2:/ {printf "%s ", $4}') # combine lines
EOF