cURL and variables


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cURL and variables
# 1  
Old 07-01-2011
cURL and variables

I have a spent a day with Google trying to figure this one out and have decided its time to ask the experts...

I'm running OS X 10.6
I need to use cURL to FTP a file.

I have been successful send the file from the command line when I know the filename. My problem is that the filename changes with the date everyday and I need to make a bash script that is dynamic to either the date or the file contained in a folder. I will be running this script hourly.

The approach I am attempting is to set the name of the file contained in the folder into a variable and then placing that variable into the curl command.

I am sure my attempt is full of errors involving quotes, spaces, ect. and I greatly appreciate any help.

Thanks,
Drew

Code:
#/bin/bash
LOCALFILE= find  /Volumes/OS/Directory/*
curl -T $LOCALFILE ftp://123.123.123.123/remotedirectory/ --user username:password

# 2  
Old 07-01-2011
What's the output of:

Code:
find  /Volumes/OS/Directory/*

Also, when you're setting a variable in bash it would me more like;

Code:
LOCALFILE=$(commands -youwant torun)

# 3  
Old 07-01-2011
Thanks for the help on the variable.

I am still having some trouble with cURL

I get the error: curl: (7) couldn't connect to host

I have echoed out what I think curl is seeing after curl -T :
Code:
/Volumes/OS/Library/FileMaker Server/Data/Documents/directory/jul111_1.csv ftp://123.123.123.123/directory/ --user USERNAME:password

I wonder if the space in the directory name "FileMaker Server" is messing this up.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Curl not accepting spaces in script via variables

Hi All, I'm trying to run a script which issues rest commands via curl to an endpoint. If I put spaces in fields via something like insomnia, it works, but when I try from an input file, it's failing with a json error. while IFS=, read mname oname <------ my input file... (10 Replies)
Discussion started by: say170
10 Replies

2. Shell Programming and Scripting

HELP - loop a curl command with different variables from input file

Hi guys! Kind of new to bash scripting and now I'm stuck. I need to curl with these variables: "{ \"nodename\": \"$1\", \"ipaddress\": \"$2\", \"poolname\": \"$3\", \"port\": \"$4\", \"loadbalancer\" : \"$5\" }" and my input_file.txt contains server001 10.10.10.01 serverpool1 80... (4 Replies)
Discussion started by: yort
4 Replies

3. Shell Programming and Scripting

Sending awk variables into curl in a bash script

Hello experts! I have a file1 with the following format (yr,day, month, hour,minute): 201201132435 201202141210 201304132030 201410100110 ... What i want to do is to assign variables and then use them in the curl command to download the text of each event from a web page. What I have... (6 Replies)
Discussion started by: phaethon
6 Replies

4. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

5. Shell Programming and Scripting

Running a script with multiple variables like 25 variables.

Hi All, i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way?? #!/bin/ksh ##script is sample.ksh age=$1 gender=$2 class=$3 . . .... (3 Replies)
Discussion started by: Lakshman_Gupta
3 Replies

6. Shell Programming and Scripting

Help with cURL

Hi all; first of all i need to clarify that i am new to apache2 server configuration and for some needs i want to transfer some files using curl to web directory,so please bear with me: following is the command i m running to transfer file to my web directory: curl -T "q"... (4 Replies)
Discussion started by: arien001
4 Replies

7. Shell Programming and Scripting

Passing variables to cli curl

I have a script that uses cli curl, and it would be easier if it was possible to pass variables like this: curl -c $cookie -d $data www.********.comThis doesn't work, instead I have to generate a string and use eval. Is there another, easier way to pass variables to cli curl? (1 Reply)
Discussion started by: locoroco
1 Replies

8. Programming

How to convert byteArray variables to HexaString variables for Linux?

Hello everybody, I am having problem in converting byte array variables to Hexa String variables for Linux. I have done, converting byte array variables to Hexa String variables for Windows but same function doesn't work for linux. Is there any difference in OS ? The code for Windows is given... (2 Replies)
Discussion started by: ritesh_163
2 Replies

9. Shell Programming and Scripting

use of curl

I have to transfer a file from my aix box to another server using ftps protocol, how can i achieve this using curl preferably or any other utility. Regards Sandeep (0 Replies)
Discussion started by: jayawantsandeep
0 Replies

10. Shell Programming and Scripting

curl

Aren't there any way to download files as below? For example, I want to download all .html files under the root directory of unix.com/ curl -O https://www.unix.com/*.html This won't work, but please tell me the way to do this. Well, the best way is to get the file list of the directory, but i... (6 Replies)
Discussion started by: Euler04
6 Replies
Login or Register to Ask a Question